34

Before, I used git locally without using .gitignore Afterwards, I created an .gitignore file, and write all unnecessary files in it. When I push them to git repo, fatal: The remote end hung up unexpectedly error appears.

I dont want to push ignore files, but, somehow git tries to push them to repo.

Please help me, what is my fault? Thanks

5
  • You donts want to push the big files or the .gitignore ? Commented Oct 5, 2015 at 16:24
  • I dont want to push all files in .gitignore Commented Oct 5, 2015 at 16:30
  • I came here after googling how to block such Git pushes in the first place. I asked about that here. Commented Jun 11, 2022 at 23:39
  • Related: stackoverflow.com/questions/2100907/… Commented Jun 11, 2022 at 23:39
  • the best answer for it is over at stackoverflow.com/a/77547007/11472644 Commented Nov 25, 2023 at 9:44

1 Answer 1

53

GitHub has a nice article on this. You basically want to remove the files from Git history, but not from the file system.

  • If your file was pushed in your last commit, you can do:

    git rm --cached path/to/your/big/file git commit --amend -CHEAD git push 
  • If not, they recommend using BFG–a tool for cleaning up repositories (alternative to git-filter-branch):

    bfg --strip-blobs-bigger-than 50M 

    This will remove files bigger than 50M.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the link to the github article! I was missing the git commit --amend -CHEAD and was going insane!
Not sure why all other answers of stackoverflow are more complicated than this

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.