2012-07-17 56 views

回答

3

是的,你可以添加一個後結帳鉤(described here)。

基本上,創建.git/hooks/post-checkout文件,並把你想運行的任何git命令放在裏面,最後確保這個文件是可執行文件(chmod +x .git/hooks/post-checkout在類似Unix的系統上,比如Mac OS,GNU/Linux等) 。

例如,如果您將git show置於該文件中,它將自動向您顯示上次提交以及每次切換分支時所做的更改。

+0

爲將來肯定有用。謝謝! – iCodeLikeImDrunk 2012-07-17 14:29:50

1

有多種git log參數來控制其輸出:

--branches--glob--tag--remotes選擇哪些承諾表明,--no-walk避免顯示所有歷史記錄(只是他們的技巧,只要你想),--oneline僅示出了提交日誌的第一行,並--decorate--color=always添加更多的眼睛糖果:d

嘗試這些命令:

$ # show the first line of the commit message of all local branches 
$ git log --oneline --decorate --color=always --branches --no-walk 

$ # show the whole commit message of all the branches that start with "feature-" 
$ git log --decorate --color=always --branches='feature-*' --no-walk 

$ # show the last commit of all remote and local branches 
$ git log --decorate --color=always --branches --remotes --no-walk 

$ # show the last commit of each remote branch 
$ git fetch 
$ git log --decorate --color=always --remotes --no-walk 

BTW,沒有必要改用樹枝看其他分支的提交:

$ # show the 'otherbranch' last commit message 
$ git log --decorate --color=always -n 1 otherbranch 

$ # show a cool graph of the 'otherbranch' history 
$ git log --oneline --decorate --color=always --graph otherbranch 
+0

好吧,我找到了正確的開關來避免遍歷分支歷史,使用'--no-walk'和'--branches' – KurzedMetal 2012-07-17 14:43:04

相關問題