Git推送到单个分支

时间:2018-01-12 13:02:23

标签: git branch

我有一个回购,我想推进develop分支。

我用过

$ git checkout develop
Already on 'develop'
Your branch is up-to-date with 'origin/develop'.

还完成了git pull分支的develop

我希望

$ git push

推动发展部门。但这不是正在发生的事情。

djave at djave-comp in ~/projects/project on develop*
$ git push
Counting objects: 49, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (49/49), done.
Writing objects: 100% (49/49), 25.45 KiB | 0 bytes/s, done.
Total 49 (delta 38), reused 0 (delta 0)
To bitbucket.org:djave/project.git
   f311657..16b42c7  develop -> develop
 ! [rejected]        master -> master (non-fast-forward)
error: failed to push some refs to 'djave@bitbucket.org:djave/project.git'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. Check out this branch and integrate the remote changes
hint: (e.g. 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

看起来它正推向develop

   f311657..16b42c7  develop -> develop

但后来也试图推进master分支(并失败):

 ! [rejected]        master -> master (non-fast-forward)

我希望它只是推向develop分支并获得成功。

如何将git push推送到develop分支?

很抱歉,如果这是重复的(已广泛搜索但找不到合适的问题组合)或标题没有使用正确的术语(随时更新标题) < / p>

1 个答案:

答案 0 :(得分:0)

不要单独使用git push,该命令可以有参数:

git push <remote_alias> <branch_name>

因此,在您的情况下,您可以使用:

git push origin develop