I am getting this error when I try to push to git and I have no idea how to fix it.
Counting objects: 1239, done.
Delta compression using up to 4 threads.
Compre
I faced the same issue recently, you can actually just filter the branch for specific file and remove it -
git filter-branch --tree-filter 'rm -rf path/to/your/file' HEAD
git reset --soft HEAD~1
then exclude the file from the commit.
Note: Use HEAD~N to go back to N number of previous commits.
use this , go back a commit ,remove the large file from the commit if you can see it , then re commit and push.
this should solve the problem
Adding to the previous answers:
git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch path_to_the_file/your_big_file'
Additionally, when I tried to pull I got "Refusing to merge unrelated histories".
Solution was to use:
git pull origin branch_name --allow-unrelated-histories
Then solve your possible conflicts, and push this time without the big_file
.
You can revert git add before commit.
Check this question: How to undo 'git add' before commit? It should work. And don't send big files to git, it's not worthy ;)
Also, exclude your logs, by adding git ignore on your logs path.
@Daniel
You can ignore that log(s) file from git repo using .gitignore
file.
for that you have to add below line to your .gitignore
file
/log
and try to commit again.
Hope this details help you to fix your issue.
Adding to the previous answers:
We are going to remove the large file from the commit as you said
Do the push from the terminal just to get the large file path git push --set-upstream origin Remote_branch_name
, locate the large file path in the errors, something like RepositoryName/folders.../bigFileName
.
Remove the file from all the branches, git filter-branch -f --index-filter 'git rm --cached --ignore-unmatch path_and_big_file'
past the path that we found in section one instead of path_and_big_file
.
Execute git pull origin branch_name --allow-unrelated-histories
to not get unrelated histories
error
Now try to push to git, it should work