git log 詳解
阿新 • • 發佈:2019-01-14
git log 可以讓我們檢視提交commit history,接下來我們來一起探索git log提供的引數。
$ git log
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
commit f290138d329aa7aa635d88868705b23372e9f004
Author: Brian Vaughn < [email protected]>
Date: Thu Jan 10 12:56:52 2019 -0800
react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param
* ReactDebugHooks injected dispatcher ref is optional
git log預設會輸出commit hash, author, date, commit message.
1 --oneline
這個命令簡化git log的預設的輸出,僅僅輸出commit hash 前7個字串和commit message.
$ git log --oneline
0005d1e3f (HEAD -> master, origin/master, origin/HEAD) Fix typo (#14576)
f290138d3 react-debug-tools accepts currentDispatcher ref as param (#14556)
b4ad8e947 rename useImperativeMethods -> useImperativeHandle ( #14565)
ab03e3d65 Inject ReactCurrentDispatcher ref to DevTools (#14550)
19ef0ec11 Separate current owner and dispatcher (#14548)
2 --stat
--stat
:是在git log 的基礎上輸出檔案增刪改的統計資料。
$ git log --stat
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
packages/scheduler/src/Scheduler.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
commit f290138d329aa7aa635d88868705b23372e9f004
Author: Brian Vaughn <[email protected]>
Date: Thu Jan 10 12:56:52 2019 -0800
react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param
* ReactDebugHooks injected dispatcher ref is optional
packages/react-debug-tools/src/ReactDebugHooks.js | 42 ++++++++++++++++------
.../ReactHooksInspection-test.internal.js | 33 +++++++++++++++++
...eactHooksInspectionIntegration-test.internal.js | 35 ++++++++++++++++++
3 files changed, 100 insertions(+), 10 deletions(-)
3 -p
-p
:控制輸出每個commit具體修改的內容,輸出的形式以diff的形式給出。
$ git log -p
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
diff --git a/packages/scheduler/src/Scheduler.js b/packages/scheduler/src/Scheduler.js
index 480ec81c4..a6e27850d 100644
--- a/packages/scheduler/src/Scheduler.js
+++ b/packages/scheduler/src/Scheduler.js
@@ -194,7 +194,7 @@ function flushWork(didTimeout) {
firstCallbackNode !== null &&
!(enableSchedulerDebugging && isSchedulerPaused)
) {
- // TODO Wrap i nfeature flag
+ // TODO Wrap in feature flag
// Read the current time. Flush all the callbacks that expire at or
// earlier than that time. Then read the current time again and repeat.
// This optimizes for as few performance.now calls as possible.
commit f290138d329aa7aa635d88868705b23372e9f004
Author: Brian Vaughn <[email protected]>
Date: Thu Jan 10 12:56:52 2019 -0800
react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param
* ReactDebugHooks injected dispatcher ref is optional
diff --git a/packages/react-debug-tools/src/ReactDebugHooks.js b/packages/react-debug-tools/src/ReactDebugHooks.js
index 9b5a3b499..b00df7e46 100644
--- a/packages/react-debug-tools/src/ReactDebugHooks.js
+++ b/packages/react-debug-tools/src/ReactDebugHooks.js
@@ -20,7 +20,7 @@ import {
ForwardRef,
} from 'shared/ReactWorkTags';
-const ReactCurrentDispatcher = ReactSharedInternals.ReactCurrentDispatcher;
+type CurrentDispatcherRef = typeof ReactSharedInternals.ReactCurrentDispatcher;
// Used to track hooks called during a render
4 git show
git show
命令同git log -p
輸出類似,只不過它只顯示一個commit的內容,如果不指定commit hash, 它預設輸出HEAD指向commit的內容.
$ git show
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
diff --git a/packages/scheduler/src/Scheduler.js b/packages/scheduler/src/Scheduler.js
index 480ec81c4..a6e27850d 100644
--- a/packages/scheduler/src/Scheduler.js
+++ b/packages/scheduler/src/Scheduler.js
@@ -194,7 +194,7 @@ function flushWork(didTimeout) {
firstCallbackNode !== null &&
!(enableSchedulerDebugging && isSchedulerPaused)
) {
- // TODO Wrap i nfeature flag
+ // TODO Wrap in feature flag
// Read the current time. Flush all the callbacks that expire at or
// earlier than that time. Then read the current time again and repeat.
// This optimizes for as few performance.now calls as possible.
5 git shortlog
這個命令用來輸出彙總資訊,以作者進行分類。
[email protected] MINGW64 /h/tmp/git/react (master)
$ git shortlog
243083df (1):
Remove unnecessary comparison; (#11215)
839 (1):
Update Japanese translation to 75fafe1
AGCB (1):
fix spelling error: differen -> different (#14378)
git shortlog -s
:可以用來統計每個作者的commit數量
git shortlog -n
:可以用來對統計的量進行倒序排列
6 --pretty
我們可以用–pretty來自定義輸出的資訊,
`git log --pretty="%cn committed %h on %cd""
7 --author
加--author
用來過濾commit,限定輸出給定的使用者
$ git log --author="Andrew Clark"
commit 84b86471ea12bd1f5994d878a318dcdead1137e9
Author: Andrew Clark <[email protected]>
Date: Wed Dec 19 17:29:25 2018 -0800
Update CHANGELOG for 16.7
commit c695b2384fecfaeaf41e951b64fae2874f28ec12
Author: Andrew Clark <[email protected]>
Date: Wed Dec 19 17:23:14 2018 -0800
React v16.7.0
commit 1c5aa2f23a80be137aeecc808498aedc304725bb
Author: Andrew Clark <[email protected]>
Date: Tue Dec 18 11:09:44 2018 -0800
Move SchedulerFeatureFlags fork to src directory to fix lint
8 限定log輸出
直接在log命令之後,加 -n
引數即可,n表示你要輸出的數量.
$ git log -2
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
commit f290138d329aa7aa635d88868705b23372e9f004
Author: Brian Vaughn <[email protected]>
Date: Thu Jan 10 12:56:52 2019 -0800
react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param
* ReactDebugHooks injected dispatcher ref is optional
9 限定指定日期範圍的log
--after
和--before
$ git log --after '10-1-2019'
commit 0005d1e3f54b79fe4707fbccc44b89e0fb4ce565 (HEAD -> master, origin/master, origin/HEAD)
Author: Carl Mungazi <[email protected]>
Date: Sat Jan 12 05:46:05 2019 +0000
Fix typo (#14576)
commit f290138d329aa7aa635d88868705b23372e9f004
Author: Brian Vaughn <[email protected]>
Date: Thu Jan 10 12:56:52 2019 -0800
react-debug-tools accepts currentDispatcher ref as param (#14556)
* react-debug-tools accepts currentDispatcher ref as param
* ReactDebugHooks injected dispatcher ref is optional
commit b4ad8e947150a1a0b486a388e2d4762d3eee51ee
Author: Sunil Pai <[email protected]>
Date: Thu Jan 10 13:37:50 2019 +0000
rename useImperativeMethods -> useImperativeHandle (#14565)
10 控制是否顯示merge的commit
--merges
或者--no-merges
11 --decoreate
該引數用來控制log輸出時,顯示對應commit所屬的branch和tag資訊
$ git log --decorate --oneline
0005d1e3f (HEAD -> master, origin/master, origin/HEAD) Fix typo (#14576)
f290138d3 react-debug-tools accepts currentDispatcher ref as param (#14556)
b4ad8e947 rename useImperativeMethods -> useImperativeHandle (#14565)
ab03e3d65 Inject ReactCurrentDispatcher ref to DevTools (#14550)
19ef0ec11 Separate current owner and dispatcher (#14548)
a9b035b0c Separate Object.is polyfill (#14334)
547e059f0 Simplify wording of key warning (#14503)
3494ee57e Update ReactUpdateQueue.js (#14521)
fef40c061 Allow node 11 as devEngine (#14450)
659c13963 Update ReactFiberScheduler.js (#14477)
84b86471e Update CHANGELOG for 16.7
c695b2384 React v16.7.0
1c5aa2f23 Move SchedulerFeatureFlags fork to src directory to fix lint
653bc582f Create separate SchedulerFeatureFlags instead of using ReactFeatureFlags (#14455)
8bfef0da5 Make scheduler debugging feature flag static
4a1072194 (tag: v16.7.0) Memoize promise listeners to prevent exponential growth (#14429)