git コマンドレット

自分がよく使う git のコマンドのまとめ

以前のコミットに戻す

git log  ← commit のバージョンを確認
git checkout xxxxxxx

以前のコミットに戻したブランチを最新のブランチに戻す

コミットナンバーを指定して戻した場合には仮のブランチになっているので、checkout しなおす

$ git branch
* (HEAD detached at 017b272)
  master
$ git checkout master

以前のコミットから新しいブランチを作成

$ git checkout xxxxxxx -b newbranch

gitからgitの管理ファイルを抜いてエクスポート

$ git checkout-index -a -f --prefix=export/ ←最後の'/' が大事

git status で管理外のフィアルを表示しない

$ git config status.showuntrackedfiles no 
$ git status -u  ← 管理外のファイルも表示する

直前のコミットメッセージを修正

$ git commit --amend

サーバ上のブランチの確認

$ git remote show origin

https で clone したリポジトリssh に変更する

$ git remote -v  ←現在の状況を確認
$ git remote set-url orign git@github.com:user_name/repo_name ←で変更

git remote -v で origin が git@github.comほげほげになっているか確認