git diff看看合并会带来什么 [英] git diff to see what a merge would introduce

查看:46
本文介绍了git diff看看合并会带来什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我和一个朋友一直在从事一个项目. 由于我们通常在不同地区工作,因此大多数情况下合并很轻松.

So me and a friend have been working on a project. Most of the time merges are painless as we generally work in different areas.

最近,我们已经越来越多地遇到彼此,创建令人讨厌的合并(截止日期).

Recently we have been running into eachother more and more creating nasty merges (deadlines).

因此,我们开始研究合并的方式.我找到了一种使用git diff的方法:

So we began investigating ways to see what a merge would do. I found a way to use git diff:

git diff mybranch...hisbranch

这给出了很好的结果.问题是,因为它使用了最后一个共同祖先,并且祖先越来越远,所以合并中有很多垃圾在我们的两个分支中都没有更改.

This gives pretty good results. The problem is, since that it uses the last common ancestor, and that ancestor is getting farther and farther back there is a lot of junk in the merge that hasn't been changed in either of our branches.

所以我想知道是否有一种方法可以准确地可视化合并将要执行的操作.

So I'm wondering is there a way to visualize exactly what a merge would do.

我尝试过:

git diff $(git-merge mybranch hisbranch) hisbranch

似乎可以正常工作,但是我想用另一种方式可视化合并,所以我尝试了:

Which seems to work ok, but I want to visualize the merge the other way so I tried:

git diff $(git-merge hisbranch mybranch) mybranch

但是在这种情况下git-merge: command not found

有人知道一个很好的方法来获得两个分支的差异,以显示合并会带来什么吗?也许突出冲突?

Does anyone know of a good way to get a diff of two branches showing what a merge would introduce? Maybe highlight conflicts?

如果没有,是否有任何可视化工具可以使您手动进行提交,因此可以选择最佳的代码版本.

If not, is there any visual tool that will allow one to manually do a commit, so one can choose what version of the code is the best.

推荐答案

还有其他可视化方式,但是我发现最简单的方法是git merge --no-commit.在手册页中:

There are other ways to visualize what would happen, but I find the easiest is git merge --no-commit. From the man page:

--commit, --no-commit
Perform the merge and commit the result. This option can be used to override --no-commit.

With --no-commit perform the merge but pretend the merge failed and do not autocommit, to give the user a chance to inspect and further tweak the merge
result before committing.

基本上,我只是发布git merge --no-commit <branch>并检查结果.如果我不喜欢它们,则发出git merge --abort,或者如果我要提交合并,则通常按git commit进行.

Basically, I just issue git merge --no-commit <branch> and inspect the results. If I don't like them, I issue git merge --abort, or if I want to commit the merge, I proceed normally with git commit.

这篇关于git diff看看合并会带来什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆