16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

忘れがちなgitコマンドメモ

Last updated at Posted at 2014-03-14

コマンド

# 削除されたリモートブランチのローカルに残った参照を削除する
$ git remote prune origin

# mergeを取り消す
$ git reset --hard ORIG_HEAD

# コミットの取り消し
$ git reset --soft HEAD^    # ステージ済み状態に戻す(作業ディレクトリの変更は保たれる)
$ git reset HEAD^           # ステージ前状態に(作業ディレクトリの変更は保たれる)
$ git reset --hard HEAD^    # 作業ディレクトリの変更も取り消し  
$ git revert HEAD           # 直前のコミット取り消し(取り消したログを作成)

# 操作の取り消し
$ git reflog    # まずHEADの履歴を見る
$ git reset --hard HEAD@{3}     # 指定の場所(今回はHEAD@{3})まで巻き戻す

リンク

Gitでブランチを作るのを忘れてmasterにコミットしてしまったときの対処法

http://qiita.com/atskimura/items/a90dfa8bfc72e3657ef9

16
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
16
16

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?