Hi, I'm Nicholas 👋

I'm a Senior Platform Engineer

Buy Me A Coffee

How to remove wrongly committed using Git

Date published:

I came across an issue when committing a branch to my repo when working with git and terraform. I removed the large file on my project that was the issue, and it is still having the issue when running the git push.

This is the issue below.

Solution: run the command git filter-branch –tree-filter ‘rm -rf path of file’ HEAD

or

git filter-branch -f –index-filter ‘git rm –cached –ignore-unmatch path of large file’ HEAD

After running the command, you should be able to perform a git push, and it will work successfully.