I have added a file named \"file1.txt\"
to a Git repository. After that, I committed it, added a couple of directories called dir1
and dir2>
If you want to delete the file from the repo, but leave it in the the file system (will be untracked):
bykov@gitserver:~/temp> git rm --cached file1.txt
bykov@gitserver:~/temp> git commit -m "remove file1.txt from the repo"
If you want to delete the file from the repo and from the file system then there are two options:
If the file has no changes staged in the index:
bykov@gitserver:~/temp> git rm file1.txt
bykov@gitserver:~/temp> git commit -m "remove file1.txt"
If the file has changes staged in the index:
bykov@gitserver:~/temp> git rm -f file1.txt
bykov@gitserver:~/temp> git commit -m "remove file1.txt"