【問題】
% git checkout master % git pull origin master
して、ローカルのmasterをリモートのmasterと同期させ、
% git checkout hoge % git rebase master
して、hogeブランチに移動して、masterでリベースしてhogeの根元を新しいものにしようとしたら、
First, rewinding head to replay your work on top of it... Applying: hoge01 commit Using index info to reconstruct a base tree... Falling back to patching base and 3-way merge... Auto-merging SampleFile01.js CONFLICT (content): Merge conflict in SampleFile01.js Auto-merging SampleFile02.css Failed to merge in the changes. Patch failed at 0001 hoge01 commit 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".
と叱られた。
【解決】
とりあえず現状把握
% git branch (no branch) master hoge
no branchってなんやねんw
% git status
で、both modified のファイルがあったので、これを解決しにく
その後、
% git add .
して
% git rebase --continue
そうすっと、もっかい叱られて、statusしたらまたboth modifiedがあったので、それを解決して
% git add . % git rebase --continue
で、rebase成功!というメッセージが出る。やったー
【はまったポイント】
- git rebase して失敗して、色々やってもう1回rebaseしようとすると、「前回のrebaseが終わってないよ!」と叱られることがある。そん時は「rm -rf .git/rebase-apply」すれば、前回の記録は消して、はじめからやり直せる。逆にコレにはgit rebase --continueするときの情報が入ってる。
- CONFLICTがあって、both modifiedを編集しに行って、解決して、addして、まではおkだけど、commitは要らない。だってカレントブランチは(no branch)なので。このままrebase --continueするべし。
【雑感】
git、理解しだすとけっこう楽しい