Gitチートシート
ファイル名のパターンを指定して履歴を取得する
code:shell
git log -p git ls-files *file-pattern
リモートリポジトリで削除済のブランチを綺麗にする
code:shell
git fetch --prune
リモートでマージ済みのローカルブランチを削除する
code:sh
git branch -vv | grep ': gone]' | grep -v '\*' | awk '{ print $1; }' | xargs -r git branch -D
リモートブランチでローカルブランチを上書きする
code:sh
git reset --hard origin/remote_branch_name
リモートブランチを新しいローカルブランチにチェックアウト
code:shell
git checkout -b local_branch_name origin/remote_branch_name
git checkout -t origin/remote_branch_name
ステージに上げるファイル名の一覧を表示する
code:shell
git diff --name-only
直近のコミットを取り消す
code:sh
git reset --soft HEAD
rebaseを破棄する
code:sh
git rebase --abort