2013.12.31 ——— git学习之解决冲突

2013.12.31 ——— git学习之解决冲突

同步代码的时候 遇到了有冲突的情况,记一下,全部步骤如下:


git rebase –abort 放弃rebase,就是回到你执行git rebase那时的状态
git rebase --skip 直接用远程分支的取代当前分支的 也就是覆盖了本地的代码


第一次 我解决错了

$ git fetch


$ git rebase
First, rewinding head to replay your work on top of it...
Applying: hot界面微调
Using index info to reconstruct a base tree...
M /res/layout/hot_list_item.xml
<stdin>:11: trailing whitespace.
android:spacing="0dp" />
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging /res/layout/hot_list_item.xml
CONFLICT (content): Merge conflict in /res/layout/hot_list_item.xml
Failed to merge in the changes.
Patch failed at 0001 hot界面微调
Warning: Your console font probably doesn't support Unicode. If you experience s
trange characters in the output, consider switching to a TrueType font such as L
ucida Console!

The copy of the patch that failed is found in:
e:/Project/.git/rebase-apply/patch

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

这个时候 合并出错了,提示我有冲突,冲突是hot_list_item.xml
然后 我解决了冲突,也就是删除了类似于svn的那些符号

$ git rebase --continue
PhoneKankan/res/layout/hot_list_item.xml: needs merge
You must edit all merge conflicts and then
mark them as resolved using git add


按照提示 我执行了git rebase --continue 但是报错,根据提示可以知道 没有暂存

$ git status
# rebase in progress; onto f81e6c1
# You are currently rebasing branch 'feature_3.0' on 'f81e6c1'.
# (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: /res/layout/hot_carousel.xml
# modified: /src/com/phone/tab/hot/view/HotList
w.java
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: /res/layout/hot_list_item.xml
#

查看了一下状态,然后add

$ git add .

$ git commit --amend
[detached HEAD c896a87] 实现推荐页中点击全部时进入频道内容页的功能
Author:
7 files changed, 110 insertions(+), 90 deletions(-)

Warning: Your console font probably doesn't support Unicode. If you experience
trange characters in the output, consider switching to a TrueType font such as
ucida Console!

$ git status
# rebase in progress; onto f81e6c1
# You are currently rebasing branch 'feature_3.0' on 'f81e6c1'.
# (all conflicts fixed: run "git rebase --continue")
#
nothing to commit, working directory clean

$ git rebase --continue
Applying: hot界面微调
No changes - did you forget to use 'git add'?
If there is nothing left to stage, chances are that something else
already introduced the same changes; you might want to skip this patch.

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


这个错误的原因就是 我提交了,其实只需要git add就行了,然后就可以continue,而我执行了git commit并且把我的更改“hot界面微调”提交到了别人的修改“实现推荐页中点击全部时进入频道内容页的功能”里面,所以我只好放弃rebase了

git rebase –abort


正确的过程如下:


$ git fetch

$ git rebase
First, rewinding head to replay your work on top of it...
Applying: hot界面微调
Using index info to reconstruct a base tree...
M res/layout/hot_list_item.xml
<stdin>:11: trailing whitespace.
android:spacing="0dp" />
warning: 1 line adds whitespace errors.
Falling back to patching base and 3-way merge...
Auto-merging res/layout/hot_list_item.xml
CONFLICT (content): Merge conflict in res/layout/hot_list_item.xml
Failed to merge in the changes.
Patch failed at 0001 hot界面微调
Warning: Your console font probably doesn't support Unicode. If you experience
trange characters in the output, consider switching to a TrueType font such as
ucida Console!

The copy of the patch that failed is found in:
e:/Project/.git/rebase-apply/patch

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

$ git status
# rebase in progress; onto f81e6c1
# You are currently rebasing branch 'feature_3.0' on 'f81e6c1'.
# (fix conflicts and then run "git rebase --continue")
# (use "git rebase --skip" to skip this patch)
# (use "git rebase --abort" to check out the original branch)
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: res/layout/hot_carousel.xml
# modified: src/com/kankan/phone/tab/hot/view/HotListItemVi
w.java
#
# Unmerged paths:
# (use "git reset HEAD <file>..." to unstage)
# (use "git add <file>..." to mark resolution)
#
# both modified: res/layout/hot_list_item.xml
#

$ git add .

$ git status
# rebase in progress; onto f81e6c1
# You are currently rebasing branch 'feature_3.0' on 'f81e6c1'.
# (all conflicts fixed: run "git rebase --continue")
#
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# modified: /res/layout/hot_carousel.xml
# modified: /res/layout/hot_list_item.xml
# modified: /src/com/kankan/phone/tab/hot/view/HotListItemVi
w.java
#

$ git commit
Aborting commit due to empty commit message.

$ git rebase --continue
Applying: hot界面微调
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值