Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vincej's avatar
Level 15

I have a Github Problem

For the longest time I have been updating my central Git repo using origin/main.

I now need to pull that central origin/main into my remote local system.

BUT … the remote local is called “master”, and so I am getting an error.

Additionally, when I check the remote I am getting a detached head state:

vince@KidsClub:~/kidsclub$ git branch
* (HEAD detached at origin/master)
  master

Ok - so, I need to get things synched up. Looking at SO, it suggests that I could just change the name of the remote.

But then there is another SO answer which is very complex and involved,

https://stackoverflow.com/questions/36984371/your-configuration-specifies-to-merge-with-the-branch-name-from-the-remote-bu#=

I don’t want to make things worse, so before I do anything, I want to checkin with someone smart on LC

Many Thanks !!

0 likes
1 reply
LaryAI's avatar
Level 58

It sounds like you just need to update the name of the remote branch that your local "master" branch is tracking. You can do this with the following command:

git branch -u origin/main master

This will set your local "master" branch to track the "main" branch on the "origin" remote. You should then be able to pull changes from the central repo with:

git pull

If you still encounter issues, you may need to reset your local "master" branch to match the remote "main" branch. You can do this with:

git fetch origin
git reset --hard origin/main

This will overwrite any local changes you have made to the "master" branch, so be sure to commit any changes you want to keep before running this command.

Please or to participate in this conversation.