リモート情報を更新
git remote update
リモートブランチ一覧
git branch -r
リモートからブランチを取得
git branch new-branch origin/new-branch
ブランチをリモートにプッシュ
git push origin <new branch name>
ブランチ削除
git branch -d hoge
ブランチ強制削除
git branch -D hoge
(git addする前の)ローカルで変更したファイルを元に戻す。
git checkout path/to/file
変更してgit addしたファイルを、git addする前の状態に戻す。
git reset HEAD path/to/file
直前のgit commitを取り消す。git commit直前の状態(ファイルは変更されているがcommitはされていない)に戻る。
git reset --soft HEAD^
git addで新規追加したファイルを、git addする前の状態に戻す。
git rm --cached path/to/file
git addで新規追加したディレクトリを、git addする前の状態に戻す。
git rm -r --cached path/to/dir
マージ
git merge <変更点の取り込み元ブランチ>
ブランチ間の差分
git diff branch1..branch2
ブランチ間でのあるファイルの差分
git diff branch1 branch2 apath/to/file
別ブランチのファイルを取得
git checkout branch1 <file path>
stash リストから削除してかつ戻す
git stash pop
stashから0番目以外を戻す場合(1番目の例)
git stash pop stash@{1}
stash リストから削除しないで戻す (※1番を戻す)
git stash apply
# ※リストの1番め戻す
git stash apply stash@{1}
stash一覧
git stash list
stashをメッセージ付きで保存
git stash save "message"