为什么Git不允许我快进合并了?如果我试图使用——ff-only强制它,我会得到消息“致命:不可能快进,终止。”我意识到合并-no-ff有巨大的优势,但我只是不明白为什么我现在不能-ff-only ?


当前回答

我也面临着相同类型的问题,我猜我们中的许多人会面临这个问题,当我们进行结对编程时,我们也有来自其他用户的传入提交。这是我所面临的步骤,并通过git拉来解决它们——没有rebase

➜  graphql-tutorial git:(filtering)  git config pull.ff only 
➜  graphql-tutorial git:(filtering) git pull
fatal: Not possible to fast-forward, aborting.
➜  graphql-tutorial git:(filtering) git merge 
➜  graphql-tutorial git:(filtering)  git config pull.rebase false 
➜  graphql-tutorial git:(filtering) git pull                      
fatal: Not possible to fast-forward, aborting.
➜  graphql-tutorial git:(filtering) git pull --no-rebase
Merge made by the 'ort' strategy.
. <file name>
. <file name>
. <file name>
. <file name>
 5 files changed, 47 insertions(+), 9 deletions(-)
 create mode 100644 app/models/auth_token.rb

其他回答

这是因为您启用了“仅快进”选项。这里的问题是你从分支的拉取会在你的本地git中创建一个合并提交,而只有快进选项不允许在拉取时创建一个合并提交。

在一个大团队的情况下,你最终会在很多时候改变和解决冲突,因为每一个承诺都来自拉力。

我建议你从git本地配置文件中删除ff = only行。

$ CD到我的项目根目录

纳米美元

[pull]
        ff = only // remove this line
        rebase = false

这对我很有用

Git pull——no-ff

如果你面对这件事

Please enter a commit message to explain why this merge is necessary,
# especially if it merges an updated upstream into a topic branch.
#
# Lines starting with '#' will be ignored, and an empty message aborts
# the commit.

然后执行以下步骤

按我 pressEsc 新闻:wq

免责声明:这些命令将从远程分支到您的分支中带来更改。

快拉,变基。与其他解决方案不同,您不需要知道目标分支的名称。

如果你的上游分支没有设置,尝试git拉origin <branch>—rebase(在评论中归功于@Rick)

要全局设置这个选项,使用git config——global pull。rebase true(归功于@Artur Mustafin)

If

git pull

不做的把戏,如果你想合并当前的变化和变化将来自分支从原点拉,然后这样做:-

git merge origin/BRANCH_NAME

之后,解决合并冲突,如果有的话,这一天就结束了。

如果原始分支被压缩,或者有一个更改破坏了提交历史,如果你不关心本地分支提交历史,你可以重置本地分支

git checkout branchname
git reset --hard origin/branchname