Git rm - How can I delete a file from git repo

De openkb
Aller à : Navigation, rechercher

Sommaire

Questions

I have added a file named "file1.txt" to git repo. After that I committed it, added a couple directories called dir1 and dir2, and committed them to git repo.

Now the current repo has "file1.txt", dir1 and dir2.
How can I delete "file1.txt" without affecting others like dir1 and dir2?

Answers

http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-rm.html http://www.kernel.org/pub/software/scm/git/docs/v1.6.0.6/git-rm.html

git rm file1.txt
git commit -m "remove file1.txt"

But if you want to remove the file only from the Git repository and not remove it from the filesystem, use:

git rm --cached file1.txt

And to push changes to remote repo

git push origin branch_name  

Source

License : cc by-sa 3.0

http://stackoverflow.com/questions/2047465/how-can-i-delete-a-file-from-git-repo

Related

Outils personnels
Espaces de noms

Variantes
Actions
Navigation
Outils