您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
07 通过git log 查看版本演...
发布时间:2020-07-04 17:45:24编辑:雪饮阅读()
oneline
git log的oneline参数可以使得git log查看的版本日志比较简洁一点,如
$ git log --oneline
48142d3 (HEAD -> master) modified index.html
b0babbd (origin/master, origin/HEAD) index
a53d498 C:/Users/xy/project/pwa3/dist/js C:/Users/xy/project/pwa3/dist/favicon.ico C:/Users/xy/project/pwa3/dist/index.html C:/Users/xy/project/pwa3/dist/manifest.json C:/Users/xy/project/pwa3/dist/precache-manifest.e8e73119b8fa65dc25182e8e58562d0c.js C:/Users/xy/project/pwa3/dist/robots.txt C:/Users/xy/project/pwa3/dist/service-worker.js C:/Users/xy/project/pwa3/dist/css C:/Users/xy/project/pwa3/dist/img
5a0cbdf Update index.md
7b60a5a Set theme jekyll-theme-cayman
n
git log的n参数可以加持行数使得git log可以仅仅查看多少指定条数的日志,如这里只查看2条日志,当然这几个参数是可以进行不同的组合的,下面这里是oneline和n参数组合了。
$ git log --oneline -n2
48142d3 (HEAD -> master) modified index.html
b0babbd (origin/master, origin/HEAD) index
branch -v
branch命令的v参数可以显示当前git仓库有多少个分支
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (master)
$ git branch -v
* master 48142d3 [ahead 1] modified index.html
checkout -b
checkout -b可以从指定版本检出创建一个新的分支
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch2)
$ git checkout -b branch3 7b60a5a
Switched to a new branch 'branch3'
A index.html2
commit -am
commit的a参数可以在提交时候自动对已跟踪文件自动放进暂存区并自动完成提交
如
$ git status
On branch branch3
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: 2.txt
no changes added to commit (use "git add" and/or "git commit -a")
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git commit -am 'modify 2.txt'
warning: LF will be replaced by CRLF in 2.txt.
The file will have its original line endings in your working directory
[branch3 b07d738] modify 2.txt
1 file changed, 1 insertion(+)
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git status
On branch branch3
nothing to commit, working tree clean
branch -av
branch -av可以查看到当前版本仓库的所有分支
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git branch -av
branch2 48142d3 modified index.html
* branch3 b07d738 modify 2.txt
master 48142d3 [ahead 1] modified index.html
temp 48142d3 modified index.html
remotes/origin/HEAD -> origin/master
remotes/origin/master b0babbd index
git log --all
git log –all命令可以查看到所有分支的版本日志,如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git log --all
commit b07d738361022b82e47953757cb226288ee7e6c3 (HEAD -> branch3)
Author: 雪饮 <1509272975@qq.com>
Date: Sat Jul 4 17:28:08 2020 +0800
modify 2.txt
commit 928b5469b5a560b98f7c2b95bc06cad44439c5fa
Author: 雪饮 <1509272975@qq.com>
Date: Sat Jul 4 17:26:45 2020 +0800
20200704
commit 8700468a425d8b0d07f37b52ede75dd5d38db15c
Author: 雪饮 <1509272975@qq.com>
Date: Sat Jul 4 17:18:24 2020 +0800
git log --all --graph
git log的graph参数可以以图形化查看版本历史,如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git log --all --graph
* commit b07d738361022b82e47953757cb226288ee7e6c3 (HEAD -> branch3)
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:28:08 2020 +0800
|
| modify 2.txt
|
* commit 928b5469b5a560b98f7c2b95bc06cad44439c5fa
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:26:45 2020 +0800
|
| 20200704
|
* commit 8700468a425d8b0d07f37b52ede75dd5d38db15c
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:18:24 2020 +0800
|
| 2,20200704
|
* commit 95b142fefb29c992bcdb3b5cd41b9d5e09adaef6
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:12:27 2020 +0800
|
| addWithCommit
:...skipping...
* commit b07d738361022b82e47953757cb226288ee7e6c3 (HEAD -> branch3)
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:28:08 2020 +0800
|
| modify 2.txt
|
* commit 928b5469b5a560b98f7c2b95bc06cad44439c5fa
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:26:45 2020 +0800
|
| 20200704
|
* commit 8700468a425d8b0d07f37b52ede75dd5d38db15c
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:18:24 2020 +0800
|
| 2,20200704
|
* commit 95b142fefb29c992bcdb3b5cd41b9d5e09adaef6
| Author: 雪饮 <1509272975@qq.com>
| Date: Sat Jul 4 17:12:27 2020 +0800
|
| addWithCommit
|
| * commit 48142d39abcd7f51c16d4eb50127445af496d056 (temp, master, branch2)
| | Author: 雪饮 <1509272975@qq.com>
| | Date: Sat Jul 4 11:27:29 2020 +0800
| |
查看指定分支日志
这里以查看branch3分支的日志为例
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git log --oneline branch3
b07d738 (HEAD -> branch3) modify 2.txt
928b546 20200704
8700468 2,20200704
95b142f addWithCommit
7b60a5a Set theme jekyll-theme-cayman
git help --web
git help的--web参数可以以浏览器的方式打开查看某个命令的帮助信息,如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/web (branch3)
$ git help commit --web
关键字词:git,log,版本,-am
上一篇:06 给文件重命名的简便方法