Created
September 15, 2014 06:00
-
-
Save hachinobu/528355340d38b09adabf to your computer and use it in GitHub Desktop.
mergeでコンフリクトした際にmerge処理前に戻す方法
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
git reset --hard ORIG_HEAD | |
git reset --hard $commit_id で現在のブランチの指す先を差し替えられますから、 git log --graph --oneline --decorate などでコミットログを表示して マージ前の状態に相当するコミット(例えばID badcafe のコミット)を探して git reset --hard badcafe とすればマージ前の状態に巻き戻すことができます。 でもこれはちょっと面倒です。 | |
実は git merge のような「危険」な(= 現在のブランチの内容を大幅に変える可能性のある)コマンドの場合、 実行前の状態を ORIG_HEAD という名前で参照できるようになっています。 つまり、わざわざコミットログを確認しなくても以下のコマンドで マージ前の状態に巻き戻すことができます: |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment