Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I ignore big files and push to git repo

Tags:

git

github

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

like image 510
Cagri Avatar asked Oct 05 '15 16:10

Cagri


People also ask

How do I ignore a large file in Git?

If the large file was added in the most recent commit, you can just run: git rm --cached <filename> to remove the large file, then. git commit --amend -C HEAD to edit the commit.

How do I push a large file to GitHub?

Open TerminalTerminalGit Bash. Change your current working directory to an existing repository you'd like to use with Git LFS. To associate a file type in your repository with Git LFS, enter git lfs track followed by the name of the file extension you want to automatically upload to Git LFS.


1 Answers

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.

like image 60
Ionică Bizău Avatar answered Sep 22 '22 18:09

Ionică Bizău