git log 命令

Git 基本操作Git 基本操作

git 可以給倉庫歷史中的某一個(gè)提交點(diǎn)打上標(biāo)簽,常常用于標(biāo)記發(fā)布結(jié)點(diǎn)( 比如:v1.0 、 v2.0 等)。

 

1. git log

git log 用于查看提交歷史記錄。

$ git log
commit d5e9fc2c811e0ca2b2d28506ef7dc14171a207d9 (HEAD -> master)
Merge: c68142b 7774248
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Fri May 3 15:55:58 2019 +0800

    Merge branch 'change_site'

commit c68142b562c260c3071754623b08e2657b4c6d5b
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Fri May 3 15:52:12 2019 +0800

    修改代碼

commit 777424832e714cf65d3be79b50a4717aea51ab69 (change_site)
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Fri May 3 15:49:26 2019 +0800

    changed the cainiaoplus.php

commit c1501a244676ff55e7cccac1ecac0e18cbf6cb00
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Fri May 3 15:35:32 2019 +0800

 

2. git log --oneline

我們可以用 --oneline 選項(xiàng)來查看歷史記錄的簡(jiǎn)潔的版本。

$ git log --oneline
d5e9fc2 (HEAD -> master) Merge branch 'change_site'
c68142b 修改代碼
7774248 (change_site) changed the cainiaoplus.php
c1501a2 removed test.txt、add cainiaoplus.php
3e92c19 add test.txt
3b58100 第一次版本提交

這告訴我們的是,此項(xiàng)目的開發(fā)歷史。

 

3. git log --graph

我們還可以用 --graph 選項(xiàng),查看歷史中什么時(shí)候出現(xiàn)了分支、合并。以下為相同的命令,開啟了拓?fù)鋱D選項(xiàng):

*   d5e9fc2 (HEAD -> master) Merge branch 'change_site'
|\  
| * 7774248 (change_site) changed the cainiaoplus.php
* | c68142b 修改代碼
|/  
* c1501a2 removed test.txt、add cainiaoplus.php
* 3e92c19 add test.txt
* 3b58100 第一次版本提交

現(xiàn)在我們可以更清楚明了地看到何時(shí)工作分叉、又何時(shí)歸并。

 

4. git log --reverse

我們可以用 --reverse 參數(shù)來逆向顯示所有日志。

$ git log --reverse --oneline
3b58100 第一次版本提交
3e92c19 add test.txt
c1501a2 removed test.txt、add cainiaoplus.php
7774248 (change_site) changed the cainiaoplus.php
c68142b 修改代碼
d5e9fc2 (HEAD -> master) Merge branch 'change_site'

 

5. git log --author

如果只想查找指定用戶的提交日志可以使用命令:git log --author , 例如,比方說我們要找 Git 源碼中 Linus 提交的部分:

$ git log --author=Linus --oneline -5
81b50f3 Move 'builtin-*' into a 'builtin/' subdirectory
3bb7256 make "index-pack" a built-in
377d027 make "git pack-redundant" a built-in
b532581 make "git unpack-file" a built-in
112dd51 make "mktag" a built-in

 

6. git log 指定日期

如果你要指定日期,可以執(zhí)行幾個(gè)選項(xiàng):--since 和 --before,但是你也可以用 --until 和 --after。

例如,如果我要看 Git 項(xiàng)目中三周前且在四月十八日之后的所有提交,我可以執(zhí)行這個(gè)(我還用了 --no-merges 選項(xiàng)以隱藏合并提交):

$ git log --oneline --before={3.weeks.ago} --after={2010-04-18} --no-merges
5469e2d Git 1.7.1-rc2
d43427d Documentation/remote-helpers: Fix typos and improve language
272a36b Fixup: Second argument may be any arbitrary string
b6c8d2d Documentation/remote-helpers: Add invocation section
5ce4f4e Documentation/urls: Rewrite to accomodate transport::address
00b84e9 Documentation/remote-helpers: Rewrite description
03aa87e Documentation: Describe other situations where -z affects git diff
77bc694 rebase-interactive: silence warning when no commits rewritten
636db2c t3301: add tests to use --format="%N"

 

7. git log -p

我們可以用 git log -p filepath 查看某個(gè)文件的詳細(xì)修改。

commit 6dd9901d6270a867d9674d674f4923dd77530ab4 (HEAD -> develop, origin/develop, origin/HEAD)Merge: cc64f62 6eae8e6
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Wed Jul 1 17:41:41 2020 +0800
    Merge branch 'bugfix/storage' into 'develop'
    set router
    See merge request std/stdcms!29
commit 6eae8e66c97d9d005121e69645018aba8a4c5fea
Author: cainiaoplus <test@cainiaoplus.com>
Date:   Wed Jul 1 17:33:45 2020 +0800

Git 基本操作Git 基本操作

丰满人妻一级特黄a大片,午夜无码免费福利一级,欧美亚洲精品在线,国产婷婷成人久久Av免费高清