LoginSignup
5
6

More than 5 years have passed since last update.

git amでコンフリクトしたときの対処

Last updated at Posted at 2017-10-10

git amでコンフリクトすると以下のように出力される

$ git am /path/to/patch
(中略)
The copy of the patch that failed is found in: .git/rebase-apply/patch
When you have resolved this problem, run "git am --continue".                                            
If you prefer to skip this patch, run "git am --skip" instead.                                           
To restore the original branch and stop patching, run "git am --abort". 

出力にあるように失敗したパッチは.git/rebase-apply/patchにコピーされているのでpatchコマンドで適用する

$ patch -p1 < .git/rebase-apply/patch
patching file Makefile.am                           
Hunk #1 succeeded at 303 (offset -25 lines).        
patching file configure.ac                          
Hunk #1 succeeded at 224 (offset -25 lines).        
Hunk #2 succeeded at 710 (offset -35 lines).        
patching file src/compositor-drm.c                  
Hunk #1 succeeded at 56 with fuzz 1 (offset -1 lines).                                                   
Hunk #2 succeeded at 115 with fuzz 2 (offset -3 lines).                                                  
Hunk #3 succeeded at 193 (offset -7 lines).         
Hunk #4 succeeded at 2162 (offset -196 lines).      
Hunk #5 succeeded at 3302 (offset -201 lines).      
Hunk #6 FAILED at 3760.                             
Hunk #7 succeeded at 3609 (offset -207 lines).      
Hunk #8 succeeded at 3675 (offset -206 lines).      
1 out of 8 hunks FAILED -- saving rejects to file src/compositor-drm.c.rej                               
patching file src/compositor-drm.h                  
Hunk #1 succeeded at 87 with fuzz 2 (offset -3 lines).                                                   
patching file src/gst-recorder.c                    
patching file src/gst-recorder.h                    
patching file src/main.c                            
Hunk #1 FAILED at 278.                              
Hunk #2 FAILED at 752.                              
2 out of 2 hunks FAILED -- saving rejects to file src/main.c.rej                                         
patching file src/media-ctl/libmediactl.c           
patching file src/media-ctl/libv4l2subdev.c         
patching file src/media-ctl/mediactl-priv.h         
patching file src/media-ctl/mediactl.h              
patching file src/media-ctl/tools.h                 
patching file src/media-ctl/v4l2subdev.h   

ここではcompositor-drm.cとmain.cへの変更が一部リジェクトされたので、compositor-drm.c.rejとmain.c.rejを眺めながら手でパッチを当てた後、変更を全て(patchコマンドで変更されたもの+手パッチしたもの)git addして

$ git am --continue

でOK。

一度に複数のパッチを適用したときも基本的に上の動作を繰り返していけば良い。

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