Obr*_*ios 10
一个快速的方法是输入
git log --pretty=format:'%h : %s' --graph
Run Code Online (Sandbox Code Playgroud)
然后沿着右侧的图表向下走,直到找到合并点。你也可以这样做
git log --pretty=format:'%h : %s' --graph > temp.txt
Run Code Online (Sandbox Code Playgroud)
它将输出放入一个文件中,temp.txt您可以在编辑器中打开该文件并使用搜索工具查找诸如合并之类的文本。
这种方法对于回答有关您最新提交的谱系的许多其他问题很有用,因此已将
alias git_graph="git log --pretty=format:'%h : %s' --graph"
Run Code Online (Sandbox Code Playgroud)
在我的.bash_profile文件中,所以我可以使用 ```git_log`` 来查看这些信息。
合并后确定提交的快速方法是使用reflog.
假设最后一次出现的操作是合并,那么:
git log HEAD@{1} -1
Run Code Online (Sandbox Code Playgroud)
HEAD@{1} 指的是上一次操作之前的前一个HEAD,因此您可以使用log和reflog来解决它.
git log将显示当前分支中的提交序列,因此在合并之后它始终是合并提交,并且在它将从合并分支提交之前.git reflog显示存储库中的操作序列(例如merge,rebase).正如文档中所解释的那样:
引用日志或"reflogs"记录在本地存储库中更新分支和其他引用的提示时.Reflog在各种Git命令中很有用,用于指定引用的旧值.
如果您已经合并branch到master,这是查找合并提交的一种方法:
# With the ancestry-path option, 'git rev-list branch..master' (or git log)
# will only list commits which are parents of 'master'
# *and* children of 'branch'
#
# If 'branch' was merged into 'master', the last commit in this list
# is the merge commit :
$ git rev-list --ancestry-path branch..master | tail -1
Run Code Online (Sandbox Code Playgroud)
master合并之前的状态是该提交的第一个父提交:
$ h=`git rev-list --ancestry-path branch..master | tail -1`
$ git log $h^
Run Code Online (Sandbox Code Playgroud)