git - 在 merge 之前查找哪些文件存在冲突?

标签 git

如果我们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 filesgit 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/

相关文章:

git - mux_client_request_session : session request failed: Session open refused by peer

git tfs branch --init --all 错误

git - git pull/clone 如何在一个网络上的 rev-list 后挂起,在其他网络上工作 : how debug and fix?

git - 能够使用一个命令推送到所有 git Remote 吗?

git - CC.net 和 GitHub 私有(private)存储库

git - Mercurial : How to do a rebase like git's rebase

git - 如何撤消向 git 添加新文件?

GitHub for Windows 表示即使差异为空,也有未提交的更改

ios - 将一个项目作为子模块添加到另一个项目

带有 Visual Studio 2015 的 Git 切换分支会导致更改