Skip to content

Instantly share code, notes, and snippets.

@iorionda
Last active December 28, 2015 09:48
Show Gist options
  • Save iorionda/7481151 to your computer and use it in GitHub Desktop.
Save iorionda/7481151 to your computer and use it in GitHub Desktop.
Git/github を使うのに便利なコマンドをまとめています
  • Git でリモートで削除されたブランチを同期させる
% git fetch --prune
  • Git でリモートのマージ済みのブランチを一括削除する
% git branch -a --merged | grep -v master | grep remotes/origin| sed -e 's% *remotes/origin/%%' | xargs -I% git push origin :%
  • Git でローカルのマージ済みのブランチを一括削除する
% git branch --merged | grep -v '*' | xargs -I % git branch -d %
  • リポジトリ内の不要なオブジェクトを削除し、最適化を行う
% git gc
  • 現在のブランチで加えた変更を見る(masterとHEAD の例)
% git diff master...HEAD
# commit名を省略するとHEADになるので
# git diff master...HEAD でもよい
  • githubのプルリクエストをローカルリポジトリへ
% git fetch origin '+refs/pull/*:refs/remotes/pr/*'
  • commitの圧縮ファイルを展開したのと同じ情報を得る
% git log --pretty=raw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment