Git跟踪一个远程分支并推送到另一个分支

时间:2017-09-04 17:38:36

标签: git github version-control bitbucket

我有一个本地功能分支说f_branch1跟踪远程分支develop。在我的一天结束时,我将我的本地分支推送到远程,这创建了一个新的远程分支f_branch1。 第二天,我从远程develop分支更新了我的本地分支,以确保我有最新的代码。现在,在今天结束时,当我尝试将我的更改推送到前一天创建的远程分支时,我收到此错误

error: failed to push some refs to 'remote url.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

这是有道理的,但是我怎样才能避免这个错误?

修改

我的意思是,因为我使用develop更新了我的本地分支,所以我的本地f_branch1的提示位于其远程f_branch1之前,这就是我收到此错误的原因。我想要的是在功能分支中远程保持我的工作安全,但同时,保持我的工作代码从公共分支develop更新。

1 个答案:

答案 0 :(得分:1)

您是如何使用develop更新分支f_branch1的?对于这种情况,你应该改变你的分支f_branch1

 git checkout f_branch1
 git rebase develop
相关问题