Unable to push changes "Failed to push some refs" EOF error
Asked by ScottBrodie:

I am unable to push changes from a branch on a repository that has been working for years, as of 3 days ago. I get the errors below, sometimes with a brief attempt to push LFS content before failing:

Pushing to bitbucket.org:ScottBrodie/wearethecaretakers2.git  
EOF  
error: failed to push some refs to 'bitbucket.org:ScottBrodie/wearethecaretakers2.git'  
Completed with errors, see above.

I can pull and fetch (From main as well as from LFS only), but cannot push. I have tried the low hanging fruit solutions such as updating SourceTree, my local embedded git, LFS pulls, using the terminal with commands from online search results, etc. I am stumped and would appreciate any leads on solutions. Hoping to avoid having to reclone and lose my recent commits on my local branch, but open to that being necessary.

Is there any way to determine if this is an issue on the bitbucket end vs something messed with refs locally? I have the 100GB LFS upgrade with only 15GB used, so I don't think it's a space issue. Perhaps with the space in the main repo? Thanks for any help, been blocked for days.


Answers:
author: Ben
body: G'day Scott,

Sometimes this issue can arise if changes have been made in the remote repository that are not present in your local repository before pushing.

If you are able to pull, yet cannot push - I would suggest rebasing your local with your remote branch before attempting to perform a subsequent push:

    git pull --rebase origin maingit push origin main

I can confirm that space is not the issue, the size of your repository is currently at 960.9MB, if you had commits which were greater in size than this limit the error would be different and state that the push is too large.

Please let me know if you are still unable to push after performing the above, there is a chance that your local repository history is messed up - in which case we can work through fixing it.

Cheers!

- Ben (Bitbucket Cloud Support)

comments: author: ScottBrodie
body: Thanks a lot for the response Ben. I have tried your suggestion and unfortunately still receive the same EOF/ref error. My output:

sbrod@MyLaptop MINGW32 /d/Projects/Wearethecaretakers2/wearethecaretakers2 (bugfix/era3_final_fixes)  
$ git pull --rebase origin bugfix/era3_final_fixes  
From bitbucket.org:ScottBrodie/wearethecaretakers2  
\* branch bugfix/era3_final_fixes -\> FETCH_HEAD  
Successfully rebased and updated refs/heads/bugfix/era3_final_fixes.

sbrod@MyLaptop MINGW32 /d/Projects/Wearethecaretakers2/wearethecaretakers2 (bugfix/era3_final_fixes)  
$ git push origin bugfix/era3_final_fixes  
EOFoading LFS objects: 100% (4/4), 16 MB \| 0 B/s  
error: failed to push some refs to 'bitbucket.org:ScottBrodie/wearethecaretakers2.git'

I also ran these commands from my default branch ("develop"), and received an "everything is up to date" response there, but when I tried to push new changes or merge in the above "era3_final_fixes" branch, I received the same errors on push.

I do believe something has gotten out of sync in my local repository related to LFS, or there are problem files in this repo. I was able to push successfully in another small repository I have that does not use LFS.

I'm still blocked by this issue so I appreciate any further suggestions!


author: Ben
body: Hey Scott,

I agree that if you are able to push changes to your remote repo - but not this particular repository, there appears to be something problematic happening on the local repo.

For this case, I would recommend first backing up any changed files which you had intended to commit.

You have two options essentially to resolve this - one is to simply delete the local repository entirely to start from a fresh slate and then perform a new clone to begin working locally again (copy changed files and push these after the fact).

The other is to attempt to repair your local branches by removing their local copies and syncing them with your remote, then resetting the local head to the current remote commit which is a more complex process that I have detailed below.  
**NOTE:** some_other_branch refers to any other branch than the one you are currently fixing, this is because you can't delete a branch while you're already inside that branch

1. Perform **git branch** command to get a list of your local branches in your local repository and copy this list somewhere, you will need to run the commands below for each branch on that list

2. Now that you have a list of the branches, you can begin fixing their commit history (commands are case sensitive):

       git checkout some_other_branchgit branch -D branch1git checkout -b branch1 origin/branch1git pull origin branch1git reset --hard origin/branch1

3. Verify that the local commit history matches the remote by comparing the commit list on your remote repo vs local:

       git log -5

4. Repeat above steps for all of the local branches and then try to push to the repo once you have finished all of these, you should see the following output which means that the local and remote branches are synced properly:

       > git push --forceEverything up-to-date

Hope this helps.

Cheers!

- Ben (Bitbucket Cloud Support)


author: ScottBrodie
body: Thank you Ben. I am in the process of deleting the local repo and recloning. I'll update the thread with the results in the next 1-2 days.


author: Ben
body: Hey Scott,

No worries, let me know how it goes.

Just a note as well, if you require lfs files to be present on your system after performing the clone (the LFS files will still be present remotely, your local will just contain pointers to these files), you can run this command afterward:

```
git lfs fetch --all
```

Cheers!

- Ben (Bitbucket Cloud Support)


Tags: atl-gruland

bitbucket-cloud

cloud