GIT:我必须不断合并我的新分支

GIT:我必须不断合并我的新分支

我已经创建了一个新的分支,并且正在与其他开发人员一起处理它,但是由于某些原因,当我想推送我的新提交时,我总是必须这样做,git merge origin/mynewbranch 否则我会收到一些错误:

 ! [rejected]        mynewbranch -> mynewbranch (non-fast-forward)
error: failed to push some refs to '[email protected]/repo.git'
To prevent you from losing history, non-fast-forward updates were rejected
Merge the remote changes before pushing again.  See the 'Note about
fast-forwards' section of 'git push --help' for details.

You asked me to pull without telling me which branch you
want to merge with, and 'branch.mynewbranch.merge' in
your configuration file does not tell me, either. Please
specify which branch you want to use on the command line and
try again (e.g. 'git pull <repository> <refspec>').
See git-pull(1) for details.

If you often merge with the same branch, you may want to
use something like the following in your configuration file:

    [branch "mynewbranch"]
    remote = <nickname>
    merge = <remote-ref>

    [remote "<nickname>"]
    url = <url>
    fetch = <refspec>

See git-config(1) for details.

为什么它不是自动的?

谢谢

答案1

从本质上来说,你没有做错什么,但是如果远程分支是由其他开发人员更新(推送)的,那么你自己的贡献(推送)将不会被直接接受。

git push(“关于快进的说明”部分)提到

您可以执行“ git pull”,解决潜在冲突,并“ git push”结果。“ git pull”将在提交 A 和 B 之间创建合并提交 C。

或者,您可以使用“ ”将 X 和 B 之间的更改重新定位到 A 之上,git pull --rebase然后将结果推回。重新定位将创建一个新的提交 D,将 X 和 B 之间的更改构建到 A 之上。

也可以看看 ”我无法在 git 上推送?” 了解更多。

相关内容