如果我们git pull
并查看:
git pull
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
那么我们可以简单地git pull --merge
1将远程 merge 到本地和 see the conflicting files与 git diff --name-only --diff-filter=U
.
但假设我们希望查看 pull 成功之前哪些文件发生冲突,即在任何文件之前发生冲突 merge 已发生。
要非常明确的是,远程上有更改,本地有更改,我想在 merge 两者之前看看有什么冲突。
1抱歉,这是错误的,但这并不重要。不过,我会找到正确的命令并很快更新。
最佳答案
stevec 的回答解释了如何在 merge 发生之前预览 merge ,这是一个不错的选择。
另一种选择是简单地执行 merge ,如果您不喜欢冲突,则可以撤消 merge 。
为此,请照常运行 git pull
。如果存在冲突并且您现在不想解决它,您可以简单地运行
git merge --abort
(或者git rebase --abort
,如果您使用git pull --rebase
)
您将回到工作目录的旧状态。请注意,只有在 pull 时没有未提交的更改时,这才会干净地工作 - 但 pull 入不干净的工作目录无论如何都不是一个好主意,因此只需在 pull 之前提交(或存储)即可。
关于git - 在 merge 之前查找哪些文件存在冲突?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70876531/