`

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界面微调

分享到:
评论

相关推荐

    Git-2.30.2-32-bit.exe.zip(免积分)

    Git-2.30.2-32-bit.exe.zip(免积分)Git-2.30.2-32-bit.exe.zip(免积分)Git-2.30.2-32-bit.exe.zip(免积分)Git-2.30.2-32-bit.exe.zip(免积分)Git-2.30.2-32-bit.exe.zip(免积分)Git-2.30.2-32-bit.exe.zip...

    Node.js-git-js一个轻量级接口用于在任何node.js应用程序中运行git命令

    git.clone('https://github.com/user/repo.git', '/local/path') .then(() =&gt; console.log('Repository cloned successfully.')) .catch(err =&gt; console.error('Error:', err)); ``` 5. **处理结果**:大部分Git...

    git-2.33.1.tar.gz

    3. 合并:Git的合并工具强大且智能,能有效解决冲突,确保多人协作时的代码一致性。 4. 版本追踪:Git提供强大的版本追踪能力,可以查看任何文件或目录在历史中的变化,以及每一次提交的详细信息。 5. 克隆与拉取...

    博主的个人git教程.zip

    博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人git教程.zip博主的个人...

    Git-2.30.2.2-64.rar

    这个压缩包包含了Git的可执行文件git.exe,它是Windows用户在命令行中运行Git命令的关键组件。 Git的核心功能包括: 1. 版本控制:Git能够记录每次对项目文件的修改,让你可以随时回滚到之前的任何版本。 2. 分支...

    Bonobo.Git.Server

    总结,Bonobo.Git.Server为小型团队提供了便捷的本地Git服务器解决方案,它的直观界面和灵活配置使得Git的使用门槛降低,提升了开发效率。通过深入了解和实践,你可以更好地利用这款工具来优化你的代码管理流程。

    git-2.37.1.tar.gz

    在团队协作中,Git还支持创建和切换分支、解决冲突、查看历史记录、回退版本等功能,是高效协同开发的关键工具。对于更高级的用法,如钩子(hooks)、工作流策略(如GitFlow或GitHub Flow)以及rebasing等,都需要...

    Git-2.33.0.2-x64-bit

    官网下载,地址:https://git-scm.com/ 下载版本:Git-2.33.0.2-64-bit.exe 安装详见...

    Git-2.45.2-64-bit.rar

    Git是世界上最流行的分布式版本控制系统,它允许开发人员协作开发软件,并跟踪每一次代码更改。这个"Git-2.45.2-64-bit.rar"压缩包包含的是Git的最新64位版本,适用于Windows操作系统。Git不断更新以提供更好的性能...

    Git-2.29.2.3-64-bit.exe (免积分)

    Git-2.29.2.3-64-bit.exe (免积分)Git-2.29.2.3-64-bit.exe (免积分)Git-2.29.2.3-64-bit.exe (免积分)Git-2.29.2.3-64-bit.exe (免积分)Git-2.29.2.3-64-bit.exe (免积分)Git-2.29.2.3-64-bit.exe (免积分)Git-2.29...

    git源码压缩包v2.42.0

    Git的强大之处还在于其丰富的命令行工具,如`git clone`用于克隆远程仓库,`git add`用于暂存更改,`git commit`用于提交更改,`git push`用于将本地更改推送到远程仓库,以及`git pull`用于从远程仓库拉取最新的...

    解决git:fatal:Unable to create”…/.git/index.lock” 的错误

    问题描述: 在使用git 进行提交时, 出现上面这个报错, 导致无法提交. 报错大致意思就是创建index.lock文件失败,因为已经存在index.lock文件了. index.lock文件是在.git下面, 而.git是一般是隐藏的, 那么可以通过以下...

    git 视频教程

    git视频教程.1.Git 命令 - git help、git config.mp4 git视频教程.2.Git 命令 - git init、git clone.mp4 git视频教程.3.1.Git 命令 - git add、git status.mp4 ...git视频教程.12.Git 命令 - 总结.mp4

    Git-2.35.1.2-64-bit.exe

    合并操作是解决冲突的关键,当多人同时修改同一部分代码时,Git可以帮助协调和解决这些问题。 在Windows上安装Git-2.35.1.2-64-bit.exe,用户通常会经历以下步骤: 1. 下载安装程序:从Git官方网站或其他可靠来源...

    git2.30.0.-64 安装包

    这有助于理解每次提交的具体变动,并在解决冲突时提供帮助。 6. **标签管理**: Git的标签功能允许开发者在特定的提交上添加标签,例如用于标记里程碑或发布版本。 7. **工作流**: Git支持多种工作流程,如GitHub ...

    git-2.41.0.tar.gz

    除了基本操作,Git还支持更高级的特性,例如交互式重置(`git reset --interactive`)、 cherry-pick(选择特定提交应用到其他分支)、rerere(用于解决冲突的自动记录和重用)等。了解并熟练掌握这些特性可以极大地...

    jenkins 2.346.1 git maven ssh插件

    jenkins 2.346.1,jdk8 适用 git maven ssh插件

    git2.34.1-64+progit原版..rar

    7. 解决冲突:阐述如何处理和解决Git合并时的冲突问题。 8. Git高级话题:涵盖子模块、rebasing、cherry-picking等进阶功能。 9. Git与其他工具的集成:介绍如何在各种开发环境中集成Git。 通过学习Pro Git,开发者...

    Git安装包 Git-2.15.1.2-64-bit和Git-2.15.1.2-32-bit以及常用命令行PDF

    8. **解决冲突**:当多个用户修改了同一部分代码时,Git会报告冲突,需要手动编辑冲突文件并重新提交。 Git-cheatsheet.PDF通常包含更全面的Git命令和操作流程,可以帮助用户快速查找和学习Git命令。它可能包括高级...

    Git2.46.2安装包(含32位和64位).zip

    官网下载的Git2.46.2标准安装包(含32位和64位).zip包含如下文件: Git-2.46.2-32-bit.exe; Git-2.46.2-64-bit.exe;

Global site tag (gtag.js) - Google Analytics