LoginSignup
4
6

More than 5 years have passed since last update.

git resetでconflictを解消する

Posted at

conflictした場合にcommitを取り消して対処するの手順

// conflict発生
$ git pull
 ! [rejected]        dev -> dev (fetch first)

// リモートとローカルのログ確認
$ git branch -a | grep dev
* dev
  remotes/origin/dev
$ git log --oneline origin/dev
14db302 fix
dc027bc third
$ git log --oneline dev
7692fd4 test
dc027bc third

// Auto-mergingされたファイルを捨てて自分の最新コミットに戻す
$ git checkout -f

// ファイルをバックアップ
$ cp 20150106.txt 20150106-1.txt

// 共通部分までコミットに戻る
$ git reset --hard dc027bc

// リモートのコミットをマージ
$ git pull

// 変更分を見ながらコミット、変更分をリモートにpush
$ diff -u 20150106-1.txt 20150106.txt

git reset --hard で指定した時点の履歴に戻る方法 | roundropブログ implements Programmable
http://blog.roundrop.jp/show/37

4
6
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
4
6