LoginSignup
4
4

More than 5 years have passed since last update.

[git ailias]本日のまとめログと最後のタグからのコミットログ、その他

Last updated at Posted at 2017-05-07

gitで便利なエイリアス達
gitやるならば最初に見ておくべきであった…

.gitconfigの[ailias]の下に書いたコマンドは
例えばgit todayなどとして実行できる。

今日一日の振り返りログ

.gitconfig
[alias]
    log1 = !git log --graph --date=relative --date-order --format=format:'%C(yellow)%h %C(bold green)[%ar] %C(reset)%s %C(red)%d %C(reset)'
    today = !git log1 --since='yesterday'  # todays work
  • --since='yesterday'で昨日(24hours以内)からの差分を取得します。
  • --date=relativeで現時刻との差

Screenshot from 2018-01-07 18-08-40.png

最後のtagからのコミットログ

.gitconfig
[alias]
    log0 = !git log --oneline
    last = !git log0 $(git tag | tail -1)..  # Latest tag
  • $(git tag | tail -1)で最新のタグを取得しています。
  • 最後の..で「最後のタグからの…」という意味になります。

Screenshot from 2018-01-07 18-06-53.png

.gitconfig
[alias]
    log2 = !git log --graph --stat --pretty=format:'%C(yellow)%h %C(cyan)%cd %C(bold black)%an %C(
red)%d %n %C(reset)%s' --date=format:'%Y-%m-%d %H:%M:%S'

Screenshot from 2018-01-07 18-01-26.png

変更したファイルのみ表示

.gitconfig
[alias]
    log3 = !git log --patch-with-stat --date=format:'%Y-%m-%d %H:%M:%S' --pretty='format:%C(yellow)%H %C(bold
cyan)[%cd] %C(bold black)%an %C(red)%d% %C(reset)%n %s'

Screenshot from 2018-01-07 18-03-22.png

--patch-with-statオプションによる差分の詳細

公式にもいいこといっぱい書いてあります。

sort

.gitconfig
[alias]
    sort = for-each-ref --sort=committerdate refs/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))'  # Display branch info

出力結果
gitsort.PNG

tagとbranchのサマリーをコミット日時でソートして表示します。

alias表示

.gitconfig
[alias]
    alias = config --get-regexp alias.*  # Display alias list

.gitconfigで指定されているaliasを表示します。

zip化

.gitconfig
[alias]
    zip = !git archive --format=zip HEAD > `git symbolic-ref --short HEAD`.zip  # Archive HEAD as zip

HEADをzipにまとめます。

4
4
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
4
4