ERROR: bitbucket gi did not send all necessary objects
Asked by pedrox5:

I'm getting the following error on one of our repositorys. I keep deleting the local and checking out a fresh instance and it works for about 10 commits and then it throws the error and keeps me from working. Any thoughts?

here is the error.

fatal: bad object refs/heads/val \[conflicted 4\] error: <https://bitbucket.org/workspace-id/repo.git> did not send all necessary objects

\[Edit: URL sanitized for privacy\]


Answers:
author: Theodora Boudale
body: Hi and welcome to the community!

I ran a git fsck on your repo and there is no corruption on the remote repo. So, the corruption seems to occur on your local repo only. It's hard to say what is causing it, though, as we don't have access to your local clone, and we don't know what operations you are performing.

If you check the references in the directory .git/refs/heads in your local clone, do the file names there match with the names of your branches (when the issue occurs)?

Kind regards,  
Theodora

comments: author: pedrox5
body: it appears in this folder I have two instances of our staging "val" and they both have bracket title additions \[conflicted 4\] and \[conflicted 5\]

Thanks for your help!

Peter


author: Theodora Boudale
body: Hi Peter,

You **may** be able to fix this in one of the following two ways (emphasis on "may", as I don't have access to your clone directory and I don't know the state of the rest of the objects). ++**Please take a backup before you proceed**++ (copy the clone directory and paste it elsewhere on that computer), in case these attempts corrupt the repo further.

**1.** If the branch named **val** exists on the remote repo, and you did not make locally any additional commits on this branch, and if the currently checked out branch in the clone is different than val, you can try deleting the files **.git/refs/heads/val \[conflicted 4\]** and **.git/refs/heads/val \[conflicted 5\]**.

I also suggest checking the files inside .**git/logs/refs/heads** to see if there are similar conflicted files in there. If there are, delete these as well.

Then, do a **git fetch** . If you want to create a local branch **val** from the remote, you can run

**git checkout -b val origin/val**

**2.** Alternatively, you can try fixing the references inside the conflicted files. If you made commits locally on **val** branch that don't exist on the remote, you need to know the hash of the last commit on **val**.

First, remove the file **.git/refs/heads/val \[conflicted 5\]** . Then, rename the file **.git/refs/heads/val \[conflicted 4\]** to **.git/refs/heads/val**. The content of the val file should be the hash of the latest commit on val branch.

You can try leaving the content of the file **.git/refs/heads/val** as is or, if this doesn't work, changing it to the content of the file **.git/refs/heads/val \[conflicted 5\]** (check your backup).

If there are logs in the folder .git/logs/refs/heads, specifically .git/logs/refs/heads/val, you can also check that file to find the last commit hash on val branch.

Kind regards,  
Theodora


author: Nicolas Grossi
body: [@pedrox5](/t5/user/viewprofilepage/user-id/1841888) Welcome! You might take a look at this link: <https://stackoverflow.com/questions/8788975/bitbucket-git-error-did-not-send-all-necessary-objects>

Nicolas

comments: author: pedrox5
body: Thank you Nic, I will take a look and see if i can get off the rocks.


Tags: bitbucket-cloud

cloud