Home Ask Login Register

Developers Planet

Your answer is one click away!

Chandu February 2016

git : remote HEAD is ambiguous - how to push changes to another branch than the cloned one?

I cloned a remote rep, master and made some changes. Before pushing changes admin has created Development branch.

Now "git remote show origin" command is showing the following ambiguous HEAD branch.

  HEAD branch (remote HEAD is ambiguous, may be one of the following):
  Remote branches:
    development new (next fetch will store in remotes/origin)
    master      tracked
  Local branch configured for 'git pull':
    master merges with remote master
  Local ref configured for 'git push':
    master pushes to master (up to date)

I already made changes to cloned master. Now, how to push changes to the newly created Development branch ?



LeGEC February 2016

If you want to have a local branch called development "linked" to the remote development branch, from your current state (eg : your master branch with extra commits), run :

# create a new branch on the current commit, and switch to it :
$ git checkout -b development  

# push your moidifcations to the remote "development" branch,
# and tag your local branch to follow the remote "development" branch :
$ git push --set-upstream origin development

If you want to push to any remote branch :

git push origin mylocalbranch:remotebranch
# for example :
git push origin master:development

# if you add '-u' or '--set-upstream', your local branch will
# follow the remote branch :
git push -u origin mylocalbranch:remotebranch

Post Status

Asked in February 2016
Viewed 2,940 times
Voted 10
Answered 1 times


Leave an answer

Quote of the day: live life