自分のマシンで git を使っているのですが、すべてのブランチとコミットの精神的なモデルを維持するのが難しいと感じています。しかし、ブランチ全体の地形を見る方法はないのでしょうか。たとえば、ブランチを説明するためにどこでも使われているアスキーマップのようなものです。
.-A---M---N---O---P
/ / / / /
I B C D E
\ / / / /
`-------------'
誰かがやってきて、私のリポジトリを拾おうとしても、何が起こっているのかを正確に把握するのは難しいように感じます。
AccuRev'のstream browserに影響されているのかもしれませんが...。
私は普段から
git log --graph --full-history --all --pretty=format:"%h%x09%d%x20%s"
色付き(シェルがBashの場合)。
git log --graph --full-history --all --color \
--pretty=format:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s"
これで、以下のようなテキストベースの表現が表示されます。
* 040cc7c (HEAD, master) Mannual is NOT built by default
* a29ceb7 Removed offensive binary file that was compiled on my machine and was hence incompatible with other machines.
| * 901c7dd (cvc3) cvc3 now configured before building
| * d9e8b5e More sane Yices SMT solver caller
| | * 5b98a10 (nullvars) All uninitialized variables get zero inits
| |/
| * 1cad874 CFLAGS for cvc3 to work succesfully
| * 1579581 Merge branch 'llvm-inv' into cvc3
| |\
| | * a9a246b nostaticalias option
| | * 73b91cc Comment about aliases.
| | * 001b20a Prints number of iteration and node.
| |/
|/|
| * 39d2638 Included header files to cvc3 sources
| * 266023b Added cvc3 to blast infrastructure.
| * ac9eb10 Initial sources of cvc3-1.5
|/
* d642f88 Option -aliasstat, by default stats are suppressed
(単に git log --format=oneline
を使用することもできますが、コミットメッセージが数字に結び付けられてしまうため、IMHOではあまり美しく見えません)。
このコマンドのショートカットを作るには、~/.gitconfig
ファイルを編集するとよいでしょう。
[alias]
gr = log --graph --full-history --all --color --pretty=tformat:"%x1b[31m%h%x09%x1b[32m%d%x1b[0m%x20%s%x20%x1b[33m(%an)%x1b[0m"
しかし、Sodel the Vociferousがコメントで指摘しているように、このような長い書式設定コマンドは覚えるのが大変です。 通常は、このコマンドを ~/.gitconfig
ファイルに記述しておけば問題ありません。 しかし、設定ファイルを変更できないリモートマシンにログインしなければならないことがある場合には、もっとシンプルだけど入力が速いバージョンを使うことができます。
git log --graph --oneline
私は、git log`で、行うことが好きです。
git log --graph --oneline --branches
(リモートブランチを表示するには --all も使用できます)
最近のGitリリースに対応:導入済み *1.6.3**以降 (Thu, 7 May 2009)
- log系コマンドのオプションである"
--pretty=<style>
"は、"--format=<style>
"と表記されるようになりました。
さらに、--format=%formatstring
は、--pretty=tformat:%formatstring
の短縮形です。
**"--oneline
"は、"--pretty=oneline --abbrev-commit
"の同義語です。
PS D:\git\tests\finalRepo> git log --graph --oneline --branches --all
* 4919b68 a second bug10 fix
* 3469e13 a first bug10 fix
* dbcc7aa a first legacy evolution
| * 55aac85 another main evol
| | * 47e6ee1 a second bug10 fix
| | * 8183707 a first bug10 fix
| |/
| * e727105 a second evol for 2.0
| * 473d44e a main evol
|/
* b68c1f5 first evol, for making 1.0
ログ表示のスパン(コミット数)を制限することもできます。
PS D:\git\tests\finalRepo> git log --graph --oneline --branches --all -5
* 4919b68 a second bug10 fix
* 3469e13 a first bug10 fix
* dbcc7aa a first legacy evolution
| * 55aac85 another main evol
| | * 47e6ee1 a second bug10 fix
(直近の5つのコミットのみ表示)
現在選択されているソリューションで気に入らないのは
git log --graph
情報が多すぎる(簡単なサマリーを見たいだけなのに)。
PS D:\git\tests\finalRepo> git log --graph
* commit 4919b681db93df82ead7ba6190eca6a49a9d82e7
| Author: VonC <[email protected]>
| Date: Sat Nov 14 13:42:20 2009 +0100
|
| a second bug10 fix
|
* commit 3469e13f8d0fadeac5fcb6f388aca69497fd08a9
| Author: VonC <[email protected]>
| Date: Sat Nov 14 13:41:50 2009 +0100
|
| a first bug10 fix
|
gitk`は素晴らしいですが、シェルセッションを別のウィンドウに移さなければなりません。一方、直近のn個のコミットを素早く表示するだけで十分な場合もあります。