Completely remove files from Git repo and remote on GitHub

This is what you’re looking for: ignoring doesn’t remove a file. I suggest you read that page, but here’s the specific command to use: git filter-branch –index-filter \ ‘git rm -r –cached –ignore-unmatch <file/dir>’ HEAD Also, to remove all the deleted files from caches git creates, use: rm -rf .git/refs/original/ && \ git reflog expire … Read more

How to revert a “git rm -r .”?

git reset HEAD Should do it. If you don’t have any uncommitted changes that you care about, then git reset –hard HEAD should forcibly reset everything to your last commit. If you do have uncommitted changes, but the first command doesn’t work, then save your uncommitted changes with git stash: git stash git reset –hard … Read more

How can I delete a file from a Git repository?

Use git rm. If you want to remove the file from the Git repository and the filesystem, use: 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 git commit -m “remove … Read more

Ignore files that have already been committed to a Git repository [duplicate]

To untrack a single file that has already been added/initialized to your repository, i.e., stop tracking the file but not delete it from your system use: git rm –cached filename To untrack every file that is now in your .gitignore: First commit any outstanding code changes, and then, run this command: git rm -r –cached … Read more