$ git status On branch master Your branch and 'origin/master' have diverged, and have 1and 1different commits each, respectively. (use "git pull" to merge the remote branch into yours)
You have unmerged paths. (fix conflicts and run "git commit") (use "git merge --abort" to abort the merge)
Unmerged paths: (use "git add <file>..." to mark resolution)
both modified: master
no changes added to commit (use "git add"and/or "git commit -a")
冲突内容
1 2 3 4 5 6 7 8
$ cat master <<<<<<< HEAD local change 2 ======= local change 1 remote change 2 >>>>>>> 2497b92a10abea64a2cfc7072039bbf497cc11e0
$ git rebase dog First, rewinding head to replay your work on top of it... Applying:cat Applying:cat Applying:removecat dog Using index info to reconstruct a base tree... A dog Falling back to patching base and3-way merge... Removing cat Applying:cat Using index info to reconstruct a base tree... Falling back to patching base and3-way merge... Auto-merging annimal CONFLICT (add/add): Merge conflict in annimal error: Failed to merge in the changes. hint: Use 'git am --show-current-patch'to see the failed patch Patch failed at 0004cat
Resolve all conflicts manually, mark them as resolved with "git add/rm <conflicted_files>", then run "git rebase --continue". You can instead skip this commit: run "git rebase --skip". To abort andget back to the state before "git rebase", run "git rebase --abort".
解决冲突后,git add ,然后git rebase --continue 无需git commit
1 2 3 4 5
$ git add annimal
$ git rebase --continue Applying:cat
查看git log已经解决分叉情况
结论
只对尚未推送或分享给别人的本地修改执行变基操作清理历史
从不对已推送至别处的提交执行变基操作
如果存在冲突,则解决完冲突后,进行git add,之后不需要git commit,直接使用git rebase --continue