私のGit活用術 2012年編 - otsune tumblr まとめサイト 画像保管庫Q




fujimuradaisuke:

いらないブランチが増えすぎた

$ git branch | grep -v master | xargs git branch -d

いらないリモートブランチが増えすぎた

最新のコミットをパッチにしてSkypeで送る

ペアプログラミングで便利。

$ git commit -a -m WIP
$ git format-patch HEAD~1
$ open .
$ # Skypeのチャットにdrag & drop

受け取った人は

$ git am ~/Downloads/0001-WIP.patch

Dropboxに共有フォルダを作っておくと更に楽です。

前のコミットにブチ込みたい

無精者のalias

~/.zshrc にて

alias g='git'
alias s='git status'
alias d='git diff'
alias m='git checkout master'

s は特にお勧め。

リモートブランチ使いが激しい人向け

~/.gitconfig にて

[alias]
  f               = fetch
  fu              = fetch upstream
  mum             = merge upstream/master
  rum             = rebase upstream/master

upstream を本流にしてる人は便利なはず。

リベースの小技

git rebase -i 中にどうしても s で別れてくれない行があるときは e するとパッチ形式で直接編集できる。

このブランチをあのブランチにpushしたい

$ git push origin kono_branch:ano_branch

俺、最近どんなコミットしたっけ…?

$ git log -p --author=fujimura

2つ前までのcommit hashが欲しい

$ git log -2 --pretty='%h'
otsune
Source: fujimuradaisuke
Comments (103 notes)

Comments

  1. yushi reblogged this from fujimuradaisuke
  2. app--tumb reblogged this from otsune
  3. jintonny reblogged this from otsune
  4. whiterain1220 reblogged this from otsune
  5. criff reblogged this from false
  6. false reblogged this from otsune
  7. flow7 reblogged this from otsune
  8. lugecy reblogged this from fujimuradaisuke
  9. shuji reblogged this from otsune and added:
    いらないブランチが増えすぎた $...branch | grep -v master | xargs git branch -d いらないリモートブランチが増えすぎた...
  10. inetgate reblogged this from fujimuradaisuke
  11. leafysho reblogged this from tatsukii
  12. ken0205 reblogged this from otsune
  13. futsu- reblogged this from otsune
  14. moriwaka reblogged this from otsune
  15. ca5 reblogged this from otsune
  16. akochan reblogged this from tatsukii
  17. deko-reblog reblogged this from otsune
  18. technobreaker reblogged this from otsune
  19. tokada reblogged this from syoichi
  20. be-under-reconstruction reblogged this from otsune
  21. ynakajima reblogged this from otsune
  22. mteramoto reblogged this from otsune
  23. tatsukii reblogged this from otsune
  24. takayah reblogged this from otsune
  25. yamaeda reblogged this from otsune
  26. hsmt reblogged this from otsune
  27. es-s-etc reblogged this from otsune
  28. nothot reblogged this from otsune
  29. tsupo reblogged this from otsune
  30. dr-caligari reblogged this from otsune
  31. lequinharay reblogged this from otsune
  32. taruyff reblogged this from otsune and added:
    いらないブランチが増えすぎた $...branch | grep -v master | xargs git branch -d いらないリモートブランチが増えすぎた...