git rebaseしてからgit pull --rebase
GitHubでHomebrewをcloneしたリポジトリを手元のリポジトリでリモートとして追加してある状態で、本家(origin/master)とclone(myfork/master)の差が激しくなってしまい、git pull origin
などとすると大量にconflictしてしまった。
% git branch master * myfork % git pull origin (以下大量のconflict報告を省略)
ちまちまと解決するのが嫌で他に方法がないかと探してみると、git rebase
すれば良いらしいので試した。
(git reset --hard実行済み) % git rebase origin First, rewinding head to replay your work on top of it... Applying: lcov formula Using index info to reconstruct a base tree... <stdin>:39: trailing whitespace. <stdin>:43: trailing whitespace. <stdin>:44: trailing whitespace. <stdin>:49: trailing whitespace. <stdin>:57: space before tab in indent. $(wildcard rpm/*) lcovrc warning: 5 lines add whitespace errors. Falling back to patching base and 3-way merge... Auto-merging Library/Formula/lcov.rb CONFLICT (add/add): Merge conflict in Library/Formula/lcov.rb Failed to merge in the changes. Patch failed at 0001 lcov formula When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". zsh: exit 1 % git rebase --skip HEAD is now at c3809f4 added cabextract dependency to winetricks Applying: autoconf-archive formula Using index info to reconstruct a base tree... <stdin>:18: trailing whitespace. warning: 1 line adds whitespace errors. Falling back to patching base and 3-way merge... Auto-merging Library/Formula/autoconf-archive.rb CONFLICT (add/add): Merge conflict in Library/Formula/autoconf-archive.rb Failed to merge in the changes. Patch failed at 0002 autoconf-archive formula When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". zsh: exit 1 % git rebase --skip HEAD is now at c3809f4 added cabextract dependency to winetricks Applying: lcov formula Using index info to reconstruct a base tree... <stdin>:39: trailing whitespace. <stdin>:43: trailing whitespace. <stdin>:44: trailing whitespace. <stdin>:49: trailing whitespace. <stdin>:57: space before tab in indent. $(wildcard rpm/*) lcovrc warning: 5 lines add whitespace errors. Falling back to patching base and 3-way merge... Auto-merging Library/Formula/lcov.rb CONFLICT (add/add): Merge conflict in Library/Formula/lcov.rb Failed to merge in the changes. Patch failed at 0003 lcov formula When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". zsh: exit 1 % git rebase --skip HEAD is now at c3809f4 added cabextract dependency to winetricks Applying: autoconf-archive formula Using index info to reconstruct a base tree... <stdin>:18: trailing whitespace. warning: 1 line adds whitespace errors. Falling back to patching base and 3-way merge... Auto-merging Library/Formula/autoconf-archive.rb CONFLICT (add/add): Merge conflict in Library/Formula/autoconf-archive.rb Failed to merge in the changes. Patch failed at 0004 autoconf-archive formula When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". zsh: exit 1 % git rebase --skip HEAD is now at c3809f4 added cabextract dependency to winetricks Applying: stow formula Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging Library/Formula/stow.rb CONFLICT (add/add): Merge conflict in Library/Formula/stow.rb Failed to merge in the changes. Patch failed at 0005 stow formula When you have resolved this problem run "git rebase --continue". If you would prefer to skip this patch, instead run "git rebase --skip". To restore the original branch and stop rebasing run "git rebase --abort". zsh: exit 1 % git rebase --skip HEAD is now at c3809f4 added cabextract dependency to winetricks Nothing to do.
都合5回git rebase --skip
しているが、これらは僕がHomebrewへ行った変更で、かつすでに本家に取り込まれているものなので、仮にconflictを修正してももとに戻すだけなのでgit rebase --continue
するために必要なgit add
を行うことが出来ない(変更されていないので)。代わりにgit rebase --skip
で進めるしかない。
その後git pull origin
とすると、冒頭と同じようにconflictが大量発生したため、git reset --hard
で元の状態に戻した上でgit pull origin --rebase
とした。
% git pull --rebase First, rewinding head to replay your work on top of it... Applying: Update formula: yaz Applying: Update formula: afflib Applying: Update to Riak 0.13.0. (以下略)
最後にgit push myfork HEAD:master
でGitHubへpushして完了。
なかなかgitの細かい操作に慣れないが、普段使う分には便利だから色々やって慣れていくしかないんだろうなあ。