我想在HEAD之前显示所有提交并显示每个提交的所有分支引用

时间:2018-05-24 08:21:26

标签: git

我想在HEAD之前显示所有提交,并显示每个提交的所有分支引用。

git log --graph --decorate --oneline --all

结果:

* 48879e9 (HEAD -> testlog) test git branch
| * 5b197c5 (master) test amend  before commit is  eighth commit
| * 57484e1 eighth commit
| * 90f8daa seventh commit
| * 185410d sixth commit
| * 90864ad sixth commit
| * 5ce7d48 fourth commit
|/  
* d0e380b third commit
* def8327 second commit
* 6413042 first commit

现在我在提交' 48879e9'

我键入: git log --graph --abbrev-commit --decorate testlog

结果:

    * commit 48879e9 (testlog)
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Thu May 24 15:53:05 2018 +0800
| 
|     test git branch
| 
* commit d0e380b
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Fri May 18 11:29:11 2018 +0800
| 
|     third commit
| 
* commit def8327
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Fri May 18 11:28:36 2018 +0800
| 
|     second commit
| 
* commit 6413042
  Author: 中文姓名 <chinalilonglong@sina.com>
  Date:   Fri May 18 11:16:43 2018 +0800

如何在当前HEAD之前显示提交。

如何显示所有分支引用括号中的每个提交。

像这样:

* commit 48879e9 (testlog)
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Thu May 24 15:53:05 2018 +0800
| 
|     test git branch
| 
* commit d0e380b (master)
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Fri May 18 11:29:11 2018 +0800
| 
|     third commit
| 
* commit def8327
| Author: 中文姓名 <chinalilonglong@sina.com>
| Date:   Fri May 18 11:28:36 2018 +0800
| 
|     second commit
| 
* commit 6413042
  Author: 中文姓名 <chinalilonglong@sina.com>
  Date:   Fri May 18 11:16:43 2018 +0800

我将* commit d0e380b更改为* commit d0e380b (master)

通过这样做,我可以快速搜索当前分支的哪个分支。

1 个答案:

答案 0 :(得分:0)

分支指针或多或少只是指向特定提交的指针。 --decorate的{​​{1}}选项会将分支引用打印到分支引用的特定提交。

您的git log分支引用指向master。因此,当5b197c5分支git log时,它不会被打印,因为testlog不是5b197c5分支的一部分。

替代方法1

如果您只想在日志中看到testlog分支与主分支分开,您可以尝试: testlog 这不会产生您想要的相同结果。但是如果你运行该命令,它将在git log $(git merge-base master testlog)^..testlog分支上打印提交日志,从两个分支之间的最新公共提交开始。 (所以你知道那个命令打印的最后一次提交存在于testlogtestlog分支中。)

替代方法2

输出看起来会有很大差异,但您可以尝试使用master命令。示例(作为图片,因为正确的颜色在眼睛上更容易):

enter image description here

在这里,您可以看到git show-branchbranch3之间的最新常见提交是mastere828d00上的所有提交都存在于branch1分支中。 master是最新的提交,对所有四个分支都是通用的。等

如果分支太多,输出可能会有点乱。

相关问题