Reputation: 387
I committed some files and tried to push them to the remote repository. However, I found a large video file in the list and terminated the pushing. And then I tried to delete the file from the list and pushed again.
$git commit -m "comments" -a
$git push origin my_branch
... # I found mp4 file here and terminated push
$git rm --cached path/to/mp4
$git commit -m "comments" -a
$git push origin my_branch
Problem
git still tried to push the mp4 file to repo.
Question How do I avoid the deleted file pushing to remote repo?
PS
I also tried git rm path/to/mp4
, the file has removed from my directory but git still tried to push the file to repo
Upvotes: 5
Views: 7981
Reputation: 1323953
If the history is larger than just one commit, and the mp4 large file has been versioned in older commits, you can consider cleaning up the history of your repo with:
git filter-branch
(as in this answer),or with BFG.
bfg --strip-blobs-bigger-than 1M my-repo.git
Follow that cleanup with a git gc --aggressive --prune=now
(as explained here)
To "roll back", simply try those operations on a local clone of your current local repo (so a second local repo, clone of the first). If the end result isn't good, you can resume in the first (untouched) repo.
Upvotes: 2
Reputation: 768
From those commands it looks like the video file is still in the commit history.
Assuming you have made no other commits try the following. If you have just tweak them a bit.
Try reverting to the previous commit
git reset --soft HEAD~1
then do git status and see if you see the file
if you do. then remove it and recommit with
git commit -c ORIG_HEAD
Upvotes: 12