GIT 5 冲突解决2

使用git pull,修改conflic文件后add,在push的方法虽然简单,但是从库上可以看到一条冗余的merge信息,通过git rebase则可以避免这条冗余信息的显示。

假设本地修改完成后,开始入库,因为别人也做了修改已经入库,所以push时会返回错误信息:

[smbtest@localhost a]$ git push origin master

 ! [rejected]        master -> master (non-fast-forward)

这时可以将远端origin的信息checkout到本地,然后使用rebase命令使master分支先暂存本地的修改,与origin同步,然后将本地修改重新加回到master

[smbtest@localhost a]$ git fetch origin
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 2), reused 0 (delta 0)
Unpacking objects: 100% (3/3), done.
From ssh://sny-jira.ads.finisar.com:7999/gpon/test
   1e65431..e9a3565  master     -> origin/master
[smbtest@localhost a]$ git rebase origin/master
First, rewinding head to replay your work on top of it...
Applying: add 8a
Using index info to reconstruct a base tree...
M       b.txt
Falling back to patching base and 3-way merge...
Auto-merging b.txt
CONFLICT (content): Merge conflict in b.txt
Failed to merge in the changes.
Patch failed at 0001 add 8a

When you have resolved this problem run "git rebase --continue".
If you would prefer to skip this patch, instead run "git rebase --skip".
To check out the original branch and stop rebasing run "git rebase --abort".

[smbtest@localhost a]$ vi b.txt
[smbtest@localhost a]$ git add b.txt
[smbtest@localhost a]$ git rebase --continue
Applying: add 8a
[smbtest@localhost a]$ git push origin master
Counting objects: 5, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 301 bytes, done.
Total 3 (delta 2), reused 0 (delta 0)
To ssh://[email protected]:7999/gpon/test.git
   e9a3565..5bcc4db  master -> master
[smbtest@localhost a]$

 

你可能感兴趣的:(git,rebase,冲突解决)