Git でよく使うコマンド
よく使うやつコマンドをメモ
変更の退避
-u
オプションを付与することにより、新規追加ファイルも同時に退避してくれる
$ git stash -u
退避した変更を一覧表示
$ git stash list
退避した状態を戻す
$ git stash apply stash@{0}
ローカルで変更したファイルを元に戻す
$ git checkout HEAD [file_name]
git add(ステージング)の取り消し
基本的に最新のコミットに戻すことが多いので、[commit_hash] はHEAD
を指定する
$ git reset [commit_hash] [file_name]
追跡しないファイルとして扱う(ファイルは残したまま)
$ git rm --cached [file_name]
リモートリポジトリとの差分比較
$ git diff -- [file_name]
コミット済みタグ付け
$ git tag -a [tag_name] -m '[comment]' [commit_hash] $ git push origin [tag_name]