Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to stop pushing deleted files to remote repo?

Tags:

git

github

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

like image 821
user001 Avatar asked Dec 26 '22 09:12

user001


1 Answers

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
like image 92
Bachmann Avatar answered Jan 05 '23 20:01

Bachmann