Skip to content

Instantly share code, notes, and snippets.

@DQNEO
Forked from teppeis/tenkaichi-git.md
Last active December 19, 2015 02:09
Show Gist options
  • Save DQNEO/5881155 to your computer and use it in GitHub Desktop.
Save DQNEO/5881155 to your computer and use it in GitHub Desktop.
ぎっとぎとにしてやんよ

ぎっとぎとにしてやんよ

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

.gitconfig

[user]
    name = teppeis
    email = [email protected]
[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 = tracking
[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がくっそ便利。

  • 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}

その他

  • fugitive.vim
  • tig
  • hug & GitHub API (特にNotification)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment