git:远程HEAD是不明确的 - 如何将更改推送到另一个分支而不是克隆的分支?

时间:2016-02-08 07:40:25

标签: git branch clone

我克隆了一个远程代表 master 并进行了一些更改。在推送更改之前,admin已创建开发分支。

现在" git远程显示原点"命令显示以下不明确的HEAD分支。

  HEAD branch (remote HEAD is ambiguous, may be one of the following):
    development
    master
  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)

我已经对克隆的进行了更改。现在,如何将更改推送到新创建的开发分支?

由于

1 个答案:

答案 0 :(得分:0)

如果您希望将一个名为development的本地分支“链接”到远程development分支,从当前状态(例如:您的master分支进行额外提交),运行:

# 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

如果你想推送到任何远程分支:

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