我有一个git分支(例如主线),我想合并到另一个开发分支中。还是我?
为了决定我是否真的想合并这个分支,我想看一些合并将做什么的预览。最好能够查看正在应用的提交列表。
到目前为止,我能想到的最好的是合并-no-ff -no-commit,然后diff HEAD。
我有一个git分支(例如主线),我想合并到另一个开发分支中。还是我?
为了决定我是否真的想合并这个分支,我想看一些合并将做什么的预览。最好能够查看正在应用的提交列表。
到目前为止,我能想到的最好的是合并-no-ff -no-commit,然后diff HEAD。
当前回答
I do not want to use the git merge command as the precursor to reviewing conflicting files. I don't want to do a merge, I want to identify potential problems before I merge - problems that auto-merge might hide from me. The solution I have been searching for is how to have git spit out a list of files that have been changed in both branches that will be merged together in the future, relative to some common ancestor. Once I have that list, I can use other file comparison tools to scout things out further. I have searched multiple times, and I still haven't found what I want in a native git command.
以下是我的解决方案,希望对其他人有所帮助:
在这个场景中,我有一个名为QA的分支,自上一个产品发行版以来,它有许多更改。我们的最后一个产品版本被标记为“15.20.1”。我有另一个名为new_stuff的开发分支,我想合并到QA分支中。QA和new_stuff都指向“跟随”(由gitk报告)15.20.1标记的提交。
git checkout QA
git pull
git diff 15.20.1 --name-only > QA_files
git checkout new_stuff
git pull
git diff 15.20.1 --name-only > new_stuff_files
comm -12 QA_files new_stuff_files
下面是一些关于为什么我对这些特定文件感兴趣的讨论:
我如何信任Git合并?
https://softwareengineering.stackexchange.com/questions/199780/how-far-do-you-trust-automerge
其他回答
如果您和我一样,您正在寻找等价于svn update -n的文件。下面的方法似乎可以达到目的。请注意,请确保首先进行git获取,以便您的本地回购有适当的更新进行比较。
$ git fetch origin
$ git diff --name-status origin/master
D TableAudit/Step0_DeleteOldFiles.sh
D TableAudit/Step1_PopulateRawTableList.sh
A manbuild/staff_companies.sql
M update-all-slave-dbs.sh
或者如果你想要从你的脑袋到遥控器的差异:
$ git fetch origin
$ git diff origin/master
在我看来,这个解决方案比提出“合并然后中止”的顶部解决方案更容易,更不容易出错(因此风险更小)。
Pull Request——我已经使用了大部分已经提交的想法,但我也经常使用的一个想法是(尤其是来自其他开发人员的想法)做一个Pull Request,它提供了一种方便的方法,可以在合并发生之前检查所有的更改。我知道这是GitHub不是git,但它肯定是方便的。
也许这个能帮到你? git-diff-tree -比较通过两个树对象找到的blob的内容和模式
I do not want to use the git merge command as the precursor to reviewing conflicting files. I don't want to do a merge, I want to identify potential problems before I merge - problems that auto-merge might hide from me. The solution I have been searching for is how to have git spit out a list of files that have been changed in both branches that will be merged together in the future, relative to some common ancestor. Once I have that list, I can use other file comparison tools to scout things out further. I have searched multiple times, and I still haven't found what I want in a native git command.
以下是我的解决方案,希望对其他人有所帮助:
在这个场景中,我有一个名为QA的分支,自上一个产品发行版以来,它有许多更改。我们的最后一个产品版本被标记为“15.20.1”。我有另一个名为new_stuff的开发分支,我想合并到QA分支中。QA和new_stuff都指向“跟随”(由gitk报告)15.20.1标记的提交。
git checkout QA
git pull
git diff 15.20.1 --name-only > QA_files
git checkout new_stuff
git pull
git diff 15.20.1 --name-only > new_stuff_files
comm -12 QA_files new_stuff_files
下面是一些关于为什么我对这些特定文件感兴趣的讨论:
我如何信任Git合并?
https://softwareengineering.stackexchange.com/questions/199780/how-far-do-you-trust-automerge
如果你已经获取了更改,我最喜欢的是:
git log ...@{u}
这需要git 1.7。x我相信。@{u}符号是上游分支的“速记”,因此它比git log…origin/master更通用。
注意:如果你使用zsh和扩展的glog,你可能需要做一些类似的事情:
git log ...@\{u\}