LoginSignup
1
0

More than 3 years have passed since last update.

gitのツリー構造をターミナルで視覚的に表示する

Posted at

この記事は株式会社シンプルウェイ 2020 アドベントカレンダーの参加記事です。
https://qiita.com/advent-calendar/2020/simpleway

gitのコミット履歴を確認するのにSourceTree等のフリーソフトを使うことがあるが、
現在チェックアウトしているブランチからの、コミット履歴を確認するのであれば、

git log

で確認できる。

ただし、そのままだと一つ一つのコミットのハッシュやコミット登録者や日付やコメントなど
すべて詳細に表示されて可読性が悪い。
あくまで確認したいのはコミットメッセージとその履歴の流れなのである。

git logにはオプションで色々見やすくできる。

graph = log --graph --oneline --decorate --date=short --all --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\"

上記のようにコマンドを叩けば、1コミット1行でコミット履歴やマージ履歴がわかりやすく表示される。

毎回上記のコマンドを打つのは骨が折れるので、
$HOME/.gitconfig のaliasのところにコマンドを設定すると良い。

graph = log --graph --oneline --decorate --date=short --all --pretty=format:\"<%h> %ad [%an] %Cgreen%d%Creset %s\"

上記のように設定しておくと、

git graph

と打つだけで視覚的にわかりやすくコミット履歴を確認できるようになる。
--pretty=format:\"〜〜〜" の部分を修正すれば、
自分が見たいと思う情報を取捨選択できる。

※参考記事
https://wp.pxdesign.jp/2014/08/23/git-hierarchy-structure/
https://blog.toshimaru.net/git-log-graph/

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0