I have deleted some files from local computer and pushed the changes to Github. However I want to remove those changes in GitHub also. I tried git rm . Not working. Any idea how to remove those files.Here is the file I want to remove
1 Answer
If you want to remove the file from the Git repository forcefully then use -f :
git rm -f file1.txt git commit -m "remove file1.txt"
If you want to remove from github only and want in your local git rm --cached file1.txt git commit -m "remove file1.txt"
Than push to your relative branch git push origin <branch_name>
1 Comment
Afrin Gaffar
I have already deleted that file in local PC. but it shows in GitHub. Also if i want to remove that file it shows like fatal: pathspec 'doc/source/_static/images/omar/image2.jpg' did not match any files
git rmadds something. Specifically, it adds a removal. You then commit this to commit the added removal. The old files are still there in the old commits. That's how a version control system works. Every file exists forever in the form in which it's committed. If the files aren't sensitive data, and aren't problematically huge, it's not worth rewriting history to eliminate them.