0

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

3
  • Please provide enough code so others can better understand or reproduce the problem. Commented Oct 18, 2021 at 7:32
  • git rm adds 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. Commented Oct 18, 2021 at 19:30
  • If they are sensitive data, use StackOverflow's search function to find the many existing answers about removing sensitive data from GitHub. Commented Oct 18, 2021 at 19:31

1 Answer 1

2

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>

Sign up to request clarification or add additional context in comments.

1 Comment

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.