【问题标题】:Git push to single branch [duplicate]Git推送到单个分支[重复]
【发布时间】:2018-06-21 22:48:07
【问题描述】:

我有一个 repo,我想推送到 develop 分支。

我用过

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

还完成了develop 分支的git pull

我期待

$ 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 分支?

对不起,如果这是重复的(已广泛搜索但找不到正确的问题组合)或标题未使用正确的术语(请随时更新标题)

【问题讨论】:

  • @SurajRao 啊,是的——谢谢

标签: git branch


【解决方案1】:

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

git push <remote_alias> <branch_name>

所以在你的情况下你可以使用:

git push origin develop

【讨论】:

  • 这可能是一个愚蠢的问题。有没有办法说“当我在一个分支上并使用 git push 时,只推送到这个分支”?
  • 啊也许git push origin HEAD
  • @Djave 您可以为此使用配置,请参见此处:stackoverflow.com/questions/21839651/…
猜你喜欢
  • 2016-11-02
  • 2018-12-19
  • 2010-11-07
  • 1970-01-01
  • 2017-02-23
  • 2011-09-10
  • 2013-10-09
  • 2016-07-08
  • 1970-01-01
相关资源
最近更新 更多