如何在合并之前找到最后的git commit [英] How to find last git commit before a merge
问题描述
当我使用git从一个工作分支合并到我的主分支后,我有时想在合并发生之前找到最后一次提交到主分支。如何做到这一点?
After I have done a merge to my master branch from a working branch with git, I sometimes want to find to find the last commit on master before the merge happened. How do I do this?
推荐答案
快速的方法是输入
A quick way to do this is to type
git log --pretty=format:'%h : %s' --graph
然后按照右边的图表进行操作,直到找到合并点。你也可以这样做:
then just follow down the graph on the right hand side till you find the merge point. You can also do
git log --pretty=format:'%h : %s' --graph > temp.txt
将输出放入一个文件中, temp.txt
,你可以在你的编辑器中打开并使用搜索工具来查找合并文本。
which puts the output into a file, temp.txt
, that which you can open in your editor and use the search facility to look for text like merge.
这种方法对于回答大量的其他有关你最新提交的血统的问题已经提出:
This approach is useful to answer lots of other questions about the lineage of your latest commit so have put
alias git_graph="git log --pretty=format:'%h : %s' --graph"
在我的 .bash_profile
文件,所以我可以使用````git_log``来查看这些信息。
in my .bash_profile
file so I can just use ```git_log`` to see this information.
这篇关于如何在合并之前找到最后的git commit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!