Skip to content

Instantly share code, notes, and snippets.

@teppeis
Last active April 29, 2023 14:58
Show Gist options
  • Save teppeis/4117588 to your computer and use it in GitHub Desktop.
Save teppeis/4117588 to your computer and use it in GitHub Desktop.
天下一gitconfig大会

天下一gitconfig大会(サイボウズ社内git勉強会@2012/11/20)の@teppeisの資料です。

ぎっとぎとにしてやんよ

DojoCat

  • gistでmarkdown書いたらbookmarkletでプレゼンになるよ。
  • ↓これをBookmarkに登録してこのページで実行してみよー!
javascript:(function()%7Bvar%20s%3Ddocument.createElement(%27script%27)%3Bs.setAttribute(%27src%27,%27https://raw.github.com/teppeis/gistdeck/fix/gistdeck.js%27)%3Bdocument.getElementsByTagName(%27head%27)%5B0%5D.appendChild(s)%3B%7D)()%3B
  • 複数行のcodeとかが微妙なのでスタイル修正してます。
  • いろいろ微妙なのでたぶんもう使わないw
  • Confluenceで作ったら便利かもね。

gitコマンドランキング(自分調べ)

Nyantocat

  46834 s
  11945 l
   9471 co
   6758 d
   5657 add
   5238 fs
   4591 ci
   4505 f
   3640 pull
   3074 b
   2499 stash
   2163 show
   2161 push
   2105 ln
   1963 submodule
   1379 dc
   1274 st
   1254 rebase
   1132 rebase -i
    762 push -u
    735 help
    669 

参考: http://shokai.org/blog/archives/6186

.gitconfig

[user]
    name = teppeis
    email = teppeis@gmail.com
[include]
    path = .gitconfig.local
[core]
    excludesfile = ~/.gitignore
    # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
    pager = less -r
    editor = vi
[color]
    ui = auto   
[push]
    # push only the current branch
    default = current
[branch]
    autosetuprebase = always
[merge]
    # from 1.7.6
    ff = false
[pull]
    # from 1.7.9
    rebase = true
[alias]
    # http://oli.jp/2012/git-powerup/
    # http://blog.blindgaenger.net/advanced_git_aliases.html
    alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort
    b = branch -a
    br = browse-remote
    ci = commit 
    co = checkout
    d = diff
    dc = diff --cached
    di = diff   
    dic = diff --cached
    f = fetch --prune
    fs = !git f && git su
    ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $1 >> .gitignore
    info = remote show origin
    l = log --graph -n 20 --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(green)- %an, %cr%Creset'
    ll = log --stat --abbrev-commit
    ln = log --graph -n 20 --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(green)- %an, %cr%Creset' --name-status
    lp = log --oneline -n 20 -p
    ls = log --stat --abbrev-commit -n 1 # display previous log
    s = status --short --branch
    st = status 
    su = submodule update

# git-browse-remote
# http://subtech.g.hatena.ne.jp/motemen/20120917/1347889804
[web]
    browser = google-chrome
[browse-remote "github.com"]
        top = https://{host}/{path}
        ref = https://{host}/{path}/tree/{short_ref}
        rev = https://{host}/{path}/commit/{commit}
[browse-remote "github.dev.cybozu.co.jp"]
        top = https://{host}/{path}
        ref = https://{host}/{path}/tree/{short_ref}
        rev = https://{host}/{path}/commit/{commit}
[browse-remote "git.dev.cybozu.co.jp"]
    top = http://{host}/graph/{path[1]}
    ref = http://{host}/changelog/~br={short_ref}/{path[1]}
    rev = http://{host}/changelog/{path[1]}?cs={commit}
[browse-remote "review.dev.cybozu.co.jp"]
    top = http://{host}/graph/{path[1]}
    ref = http://{host}/changelog/~br={short_ref}/{path[1]}
    rev = http://{host}/changelog/{path[1]}?cs={commit}

[include]

ないしょの鍵とかトークンとかを別ファイルで保存できるよ(git 1.7.10から)。

[include]
    path = .gitconfig.local

.gitignore

オレオレgitignoreがくっそ便利。svnではできなかった。svnでも指定できたみたいです。コメ欄参照 thanks! @thinca

  • repo/.gitignore : 特定リポジトリで全メンバー共有
  • repo/.git/info/exclude : 特定リポジトリで自分だけ
  • core.excludesfile : 全リポジトリで自分だけ
[core]
    excludesfile = ~/.gitignore

GitHub直伝 gitignoreコレクション

https://github.com/github/gitignore

基本的なところ

[core]
    # http://stackoverflow.com/questions/136178/git-diff-handling-long-lines
    pager = less -r
    editor = vi
[color]
    ui = auto   

push & rebase & merge

[push]
    # push only the current branch
    default = tracking
[branch]
    autosetuprebase = always
[merge]
    # from 1.7.6
    ff = false
[pull]
    # from 1.7.9
    rebase = true

余談

  • いまググると「gitではmerge --no-ff, pull --rebaseをデフォルトにできない」っていう昔の記事がたくさんひっかかるけど、できるようになってるよ。
  • man git-config するといいよ。

alias

このリンクがオススメ

[alias]
    alias = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\\t => \\2/' | sort
    b = branch -a
    br = browse-remote
    ci = commit 
    co = checkout
    d = diff
    dc = diff --cached
    di = diff   
    dic = diff --cached
    f = fetch --prune
    fs = !git f && git su
    ignore = !([ ! -e .gitignore ] && touch .gitignore) | echo $1 >> .gitignore
    info = remote show origin
    l = log --graph -n 20 --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(green)- %an, %cr%Creset'
    ll = log --stat --abbrev-commit
    ln = log --graph -n 20 --pretty=format:'%C(yellow)%h%C(cyan)%d%Creset %s %C(green)- %an, %cr%Creset' --name-status
    lp = log --oneline -n 20 -p
    ls = log --stat --abbrev-commit -n 1 # display previous log
    s = status --short --branch
    st = status 
    su = submodule update

ログフォーマット

  • git help logしたらフォーマットの意味が分かるよ。
  • 個人的にはauthor date (%a系) よりもcommitter date (%c系) が好きです。

git-browse-remote

この設定で勝つる!

[web]
    browser = google-chrome
[browse-remote "github.com"]
        top = https://{host}/{path}
        ref = https://{host}/{path}/tree/{short_ref}
        rev = https://{host}/{path}/commit/{commit}
[browse-remote "github.dev.cybozu.co.jp"]
        top = https://{host}/{path}
        ref = https://{host}/{path}/tree/{short_ref}
        rev = https://{host}/{path}/commit/{commit}
[browse-remote "git.dev.cybozu.co.jp"]
    top = http://{host}/graph/{path[1]}
    ref = http://{host}/changelog/~br={short_ref}/{path[1]}
    rev = http://{host}/changelog/{path[1]}?cs={commit}
[browse-remote "review.dev.cybozu.co.jp"]
    top = http://{host}/graph/{path[1]}
    ref = http://{host}/changelog/~br={short_ref}/{path[1]}
    rev = http://{host}/changelog/{path[1]}?cs={commit}

おまちかね

声に出して読みたい地獄のミサワ

ターン!

本物のソーシャルコーディングを教えてやる

lolcommits

  • lolcommits
  • さーせん、ローカルのMacでは動きませんでした。。

その他おもしろい&そうなやつら

  • fugitive.vim
  • tig
  • hug & GitHub API (特にNotification)

Thanks!

ChelloCat

@teppeis
Copy link
Author

teppeis commented Nov 21, 2012

@thinca ありがとうございます!global-ignores普通に知りませんでした。本文に修正しましたー。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment