Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git still tracking a file that I already deleted

I am working with a large text file that exceeds the maximum allowable file size that git allows, so it's not allowing me to push my local commits to remote. I've tried creating a .gitignore file and adding the path of the file to it, but I still get the same problem.

I've also tried:

git rm -r --cached .
git add .
git commit -m "message"
git push

As well as:

git update-index --assume-unchanged <path/to/file>

I've even deleted the file then re-commit and push:

git add .
git commit -m "message"
git push

but git still thinks I'm trying to push the large text file. I'm stumped as to how I can un-track the file from git.

like image 518
CobraPi Avatar asked Oct 18 '25 20:10

CobraPi


1 Answers

Note : git rm --cached unstage only from the index, not from the repository.

The text file has already been registered in a previous commit in your repository. Even if you try to modify your repository with new commits, the old one is still there. Git will try to push it anyway.

So you need to edit this previous commit and remove the file registered in it. You have to rewrite the history of the commits : git rebase -i specific-commit-id will be your friend. At this point, you can use git rm --cached to remove the big text file in this commit. Then git commit to update it.

like image 61
Lyokolux Avatar answered Oct 20 '25 09:10

Lyokolux



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!