[Git]git分支查询——图像化[转载]

1 git reflog

git reflog : 可查看所有分支的所有操作记录(含: commit / reset / merge / checkout等操作)

1-1 查看分支的所有变更记录(含: commit / reset / merge / checkout等)

Johnny@LAPTOP-RFPOFJM7 MINGW64 /i/Workspace-I/gitDemo (master)
$ git reflog
cbd0c2f (HEAD -> master) HEAD@{0}: reset: moving to cbd0c2ff834f267876e5c0f5267c42499ce735b6
343ff9b HEAD@{1}: reset: moving to 343ff9b
343ff9b HEAD@{2}: reset: moving to 343ff9ba021a4cebffdc03950f61669e5be51f7f
343ff9b HEAD@{3}: reset: moving to HEAD
343ff9b HEAD@{4}: reset: moving to HEAD
343ff9b HEAD@{5}: reset: moving to HEAD
343ff9b HEAD@{6}: commit: modified file5 - 2th
cbd0c2f (HEAD -> master) HEAD@{7}: commit: modified file5 - 1th
8b8044f HEAD@{8}: commit: add file5 - init
df27a4c (gitDemo-tagV1.1) HEAD@{9}: merge gitDemo-tagV1.1: Fast-forward
055244b (tag: v1.1) HEAD@{10}: checkout: moving from gitDemo-tagV1.1 to master
df27a4c (gitDemo-tagV1.1) HEAD@{11}: checkout: moving from gitDemo-tagV1.1 to gitDemo-tagV1.1
df27a4c (gitDemo-tagV1.1) HEAD@{12}: commit: add file4.txt
055244b (tag: v1.1) HEAD@{13}: checkout: moving from master to gitDemo-tagV1.1
055244b (tag: v1.1) HEAD@{14}: checkout: moving from gitDemo-tagV1.1 to master
055244b (tag: v1.1) HEAD@{15}: checkout: moving from 055244b34aa42178da034d1f5eb32989ca72a80d to gitDemo-tagV1.1
055244b (tag: v1.1) HEAD@{16}: checkout: moving from gitDemo2-dev to v1.1
45b5306 (tag: v1.0, gitDemo2-dev) HEAD@{17}: checkout: moving from master to gitDemo2-dev
055244b (tag: v1.1) HEAD@{18}: commit: add file3.txt on master branch
45b5306 (tag: v1.0, gitDemo2-dev) HEAD@{19}: merge gitDemo2-dev: Fast-forward
6ad753e HEAD@{20}: checkout: moving from gitDemo2-dev to master
45b5306 (tag: v1.0, gitDemo2-dev) HEAD@{21}: checkout: moving from master to gitDemo2-dev
6ad753e HEAD@{22}: checkout: moving from master to master
6ad753e HEAD@{23}: checkout: moving from gitDemo2-dev to master
45b5306 (tag: v1.0, gitDemo2-dev) HEAD@{24}: merge master: Merge made by the 'recursive' strategy.
e1d54b3 HEAD@{25}: checkout: moving from gitDemo2-dev to gitDemo2-dev
e1d54b3 HEAD@{26}: checkout: moving from master to gitDemo2-dev
6ad753e HEAD@{27}: commit: modified file1 -2 on master
7ebed5d HEAD@{28}: checkout: moving from gitDemo2-dev to master
e1d54b3 HEAD@{29}: commit: modified file2 on gitDemo2-dev
c476bfc HEAD@{30}: checkout: moving from master to gitDemo2-dev
7ebed5d HEAD@{31}: checkout: moving from gitDemo2-dev to master
c476bfc HEAD@{32}: commit: add file2 on gitDemo2-dev branch
7ebed5d HEAD@{33}: checkout: moving from master to gitDemo2-dev
7ebed5d HEAD@{34}: commit: modified file1 on master branch
e03aabe HEAD@{35}: commit (initial): init and add file1.txt

1-2 查看分支是基于哪个分支checkout出来的

git reflog --date=local | grep '<分支名>'

2 git log

2-1 查询分支的变化过程

--decorate 标记会让git log显示每个commit的引用(如:分支、tag等)
--oneline 一行显示
--simplify-by-decoration 只显示被branch或tag引用的commit
--all 表示显示所有的branch,这里也可以选择,比如指向显示分支ABC的关系,则将--all替换为branchA branchB branchC

Johnny@LAPTOP-RFPOFJM7 MINGW64 /i/Workspace-I/gitDemo (master)
$ git log --graph --oneline
* e9afde4 (HEAD -> master) modified file5 - 5th
* c085c9a modified file5 - 4th
* c09d26c modified file5 - 3th
* e2f910f modified file5 - 2.2th
* cbd0c2f modified file5 - 1th
* 8b8044f add file5 - init
* df27a4c (gitDemo-tagV1.1) add file4.txt
* 055244b (tag: v1.1) add file3.txt on master branch
*   45b5306 (tag: v1.0, gitDemo2-dev) Merge branch 'master' into gitDemo2-dev
|
| * 6ad753e modified file1 -2 on master
* | e1d54b3 modified file2 on gitDemo2-dev
* | c476bfc add file2 on gitDemo2-dev branch
|/
* 7ebed5d modified file1 on master branch
* e03aabe init and add file1.txt
# git log --graph --decorate --oneline --simplify-by-decoration --all

* df08309 (dev) 节目信息的反馈
| * 09a3601 (origin/master, origin/HEAD, master) 心跳修复                       
|/ 
| * aced49f (test) 计算逻辑调整
|/ 
| * 22f18e5 (HEAD, upgrade, new_branch) 机器调整
|/ 
* 6cefafe (tag: 0.6.2, 242/10.26) pid空处理
* 680a169 (tag: 0.6.0) tag: 0.6.0
* da9228e (tag: 0.5.3) recommit missing codes
* c66e1e0 (origin/dev) bitrate check

所有的tag和历史branch都会被列出来,即使branch被delete了

X 参考文献

原文地址:https://www.cnblogs.com/johnnyzen/p/13842174.html