git log查看版本历史
1.查看详细log信息
git log
2.查看简洁log信息
git log --oneline
3.指定最近的2个commit的log
git log -n2 --oneline
4.查看本地有多少分支
git branch -v
5.根据以前的版本创建临时的分支
1 2 3 4 5 6 7 8
| G:\mygitea\GitLearn\learn01 master $ git log -n2 --oneline 5bc7fdf (HEAD -> master) rename test 012ae46 e1
G:\mygitea\GitLearn\learn01 master $ git checkout -b temp 5bc7fdf Switched to a new branch 'temp'
|
修改并提交新分支,查看所有分支历史
1 2 3 4 5 6 7 8 9 10 11 12 13
| G:\mygitea\GitLearn\learn01 temp $ git log -n2 --all commit a1909d9c0f3b58619fcfde910855f05ffe8623f5 (HEAD -> temp) Author: Jabari <innocenfox@gmail.com> Date: Sat May 7 13:07:18 2022 +0800
add 5bc7fdf file
commit 5bc7fdf00745054e6ad99bbc6aceb14cdaa672d4 (master) Author: Jabari <innocenfox@gmail.com> Date: Thu May 5 19:33:57 2022 +0800
rename test
|
6.图形化查看分支
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
| G:\mygitea\GitLearn\learn01 master $ git log --oneline --all --graph * 87118bd (merge_web) create complete web page by merge 4 commit | * 9fa98d6 (fix_css) change background color | | * e1514cf (temp) test1 | | * a1909d9 add 5bc7fdf file | | * 5bc7fdf (HEAD -> master) rename test | |/ | * 012ae46 e1 | * b390c28 (origin/master) add modified html css | * 58b4bfd add js | * 1d40e3a add css | * 1580123 add html images file |/ * 3cd7fd8 add readme * df647fe Initial commit
|
7.只查看某个分支的版本历史
1 2 3 4 5 6 7 8 9 10
| G:\mygitea\GitLearn\learn01 temp $ git log --oneline master 5bc7fdf (master) rename test 012ae46 e1 b390c28 (origin/master) add modified html css 58b4bfd add js 1d40e3a add css 1580123 add html images file 3cd7fd8 add readme df647fe Initial commit
|
总结
• git log —all 查看所有分支的历史
• git log —all —graph 查看图形化的 log 地址
• git log —oneline 查看单行的简洁历史。
• git log —oneline -n4 查看最近的四条简洁历史。
• git log —oneline —all -n4 —graph 查看所有分支最近 4 条单行的图形化历史。
• git help —web log 跳转到git log 的帮助文档网页