Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Repo update not working, master behind, detached head

Tim
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
October 1, 2024

hello,

I hope anyone can help me out here, i am completely stuck in our sourcetree repo.

This is our current situation:

Sourcetree.png

We have had numerous issue with merging in the past, so i refrained from doing so for a while (all updates went manually via the colleague).
But now i want to return to co-op via sourcetree.

There are some changes i've created in my repo, which are currently committed into the "HEAD" entry. 
But i cannot push this to the cloud repo.

It complains about the master being one behind, but there doesn't seem to be anything i can do about it. 

It also keeps mentioning a detached head, i tried removing it, but it just keeps showing and in bold.

I can try to checkout any version, but it will return to this image without any message.



Yes, i'm new to this. How can i get this situation fixed so that the "head" variant is the new leading version of both my local and the remote repo (so anyone else can use it again).

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
October 2, 2024

Hi Tim and welcome to the community!

The HEAD entry refers to the commit that is currently checked out. At the time you took this screenshot, it was the commit with the hash cf8f9e7. Looking at the commit graph you posted here, it looks like this commit does not belong to master branch or any other branch. The 'detached HEAD' message means that the HEAD does not point to a branch, but to a specific commit.

Before taking any action, I suggest taking a backup of your local clone; copy the clone directory from your computer and paste it in another place, to keep it as a backup, in case something goes wrong with the steps I provide below.

 

What you can do is create another branch out of commit cf8f9e7, and then merge this branch into master:

1. Open a terminal application on your computer, and navigate to the directory of the clone.

2. Run the command git status to confirm again the detached HEAD at cf8f9e7.

3. If you see in the output 

HEAD detached at cf8f9e7

then run the following command to create a branch named temp out of this commit

git branch temp

4. Then, check out master branch and merge temp into master with the following commands:

git checkout master
git merge temp

Then, check the commit graph again in SourceTree and see if both HEAD and master point now to the same commit, and if it looks ok, you can push your changes to the remote repo.

Please feel free to let me know how it goes.

Kind regards,
Theodora

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin Site Admin
TAGS
AUG Leaders

Atlassian Community Events