git rm - Comment puis-je supprimer un fichier dans un dépôt Git

Mots clés : gitgit-rmgit

meilleur 5 Réponses git rm - Comment puis-je supprimer un fichier dans un dépôt Git

vote vote

96

git rm file1.txt git commit -m "remove file1.txt" 
git rm --cached file1.txt git commit -m "remove file1.txt" 
git push origin branch_name 
vote vote

90

[~/www]$ git rm shop/mickey/mtt_flange_SCN.7z.003 error: 'shop/mickey/mtt_flange_SCN.7z.003' has local modifications (use --cached to keep the file, or -f to force removal) [~/www]$ git rm -f shop/mickey/mtt_flange_SCN.7z.003 rm 'shop/mickey/mtt_flange_SCN.7z.003' [~/www]$  [~/www]$ git status # On branch master # Changes to be committed: #   (use "git reset HEAD <file>..." to unstage) # #   deleted:    shop/mickey/mtt_flange_SCN.7z.003 # # Changed but not updated: #   (use "git add <file>..." to update what will be committed) #   (use "git checkout -- <file>..." to discard changes in working directory) # #   modified:   shop/mickey/mtt_flange_SCN.7z.001 #   modified:   shop/mickey/mtt_flange_SCN.7z.002 [~/www]$ ls shop/mickey/mtt_flange_S* shop/mickey/mtt_flange_SCN.7z.001  shop/mickey/mtt_flange_SCN.7z.002 [~/www]$  [~/www]$  [~/www]$ git rm --cached shop/mickey/mtt_flange_SCN.7z.002 rm 'shop/mickey/mtt_flange_SCN.7z.002' [~/www]$ ls shop/mickey/mtt_flange_S* shop/mickey/mtt_flange_SCN.7z.001  shop/mickey/mtt_flange_SCN.7z.002 [~/www]$  [~/www]$  [~/www]$ git status # On branch master # Changes to be committed: #   (use "git reset HEAD <file>..." to unstage) # #   deleted:    shop/mickey/mtt_flange_SCN.7z.002 #   deleted:    shop/mickey/mtt_flange_SCN.7z.003 # # Changed but not updated: #   modified:   shop/mickey/mtt_flange_SCN.7z.001 [~/www]$ 
vote vote

71

git rm -- *.anExtension git commit -m "remove multiple files" 
vote vote

68

git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch *.sql' 
vote vote

55

git rm -r foldername 

Questions similaires