windows下git的安装、配置与操作(八)——git冲突的解决
来源:互联网 发布:高起专网络教育总学分 编辑:程序博客网 时间:2024/05/22 03:32
对分支进行合并的时候,有可能会产生冲突。冲突的解决就是要修改冲突的内容。
首先我们创建一个分支:
$ git checkout -b conflictbranchSwitched to a new branch 'conflictbranch'我们修改文件的最后一行:
$ cat readme.txtHello World!this is a git file.this file will commit to git.we are young!yes we are young!Creating a new branch is quick and simple.然后添加提交:
$ git add readme.txt$ git commit -m "and simple."[conflictbranch 4c6d3a3] and simple. 1 file changed, 1 insertion(+), 1 deletion(-)这时候我们回到master分支并对文件进行修改:
$ git checkout masterSwitched to branch 'master'Your branch is up-to-date with 'origin/master'.$ cat readme.txtHello World!this is a git file.this file will commit to git.we are young!yes we are young!Creating a new branch is quick & simple.然后我们在master分支提交:
$ git add readme.txt$ git commit -m "& simple."[master 554d2c8] & simple. 1 file changed, 1 insertion(+), 1 deletion(-)当我们试图将conflictbranch合并到master的时候,发现这里起了冲突:
$ git merge conflictbranchAuto-merging readme.txtCONFLICT (content): Merge conflict in readme.txtAutomatic merge failed; fix conflicts and then commit the result.当我们查看状态的时候:
$ git statusOn branch masterYour branch is ahead of 'origin/master' by 1 commit. (use "git push" to publish your local commits)You have unmerged paths. (fix conflicts and run "git commit")Unmerged paths: (use "git add <file>..." to mark resolution) both modified: readme.txtno changes added to commit (use "git add" and/or "git commit -a")原来是都修改了readme.txt文件。
我们查看文件的内容发现了冲突的位置:
$ cat readme.txtHello World!this is a git file.this file will commit to git.we are young!yes we are young!<<<<<<< HEADCreating a new branch is quick & simple.=======Creating a new branch is quick and simple.>>>>>>> conflictbranch我们可以直接对文件内容进行修改:
$ cat readme.txtHello World!this is a git file.this file will commit to git.we are young!yes we are young!Creating a new branch is quick and simple.然后再提交:
$ git add readme.txt$ git commit -m "conflict fixed"[master a6791d5] conflict fixed通过日志可以看到详细的合并过程:
$ git log --pretty=oneline --graph -4* a6791d55e3526f4c9f6f137a21801af61a13d3e2 conflict fixed|\| * 4c6d3a3aaa89f1d9954340af0cb2641f3f95dba7 and simple.* | 554d2c80016370b6e88a596f12fc282a3d820e8a & simple.|/* ecf03eb78643b6b7eafcc9e27848d8eba51462c6 branch dev modify最后就可以删除分支conflictbranch:
$ git branch -d conflictbranchDeleted branch conflictbranch (was 4c6d3a3).
0 0
- windows下git的安装、配置与操作(八)——git冲突的解决
- windows下git的安装、配置与操作(九)——git标签的操作
- windows下git的安装、配置与操作(十)——自定义git
- windows下git的安装、配置与操作(一)——安装与配置
- windows下git的安装、配置与操作(十一)——分支的管理
- windows下git的安装、配置与操作(二)——文件修改
- windows下git的安装、配置与操作(三)——版本回退
- windows下git的安装、配置与操作(七)——分支创建于合并的操作演示
- windows下git的安装、配置与操作(六)——远程仓库(建立与github的联系)
- windows下git的安装、配置与操作(五)——文件的修改与删除
- Windows下GIT的安装与配置
- windows下git的安装、配置与操作(四)——工作区与暂存区
- windows下git的安装、配置与操作(七)——git创建与合并分支(转载自廖雪峰)
- Git下的冲突解决
- Git下的冲突解决
- Git下的冲突解决
- Git下的冲突解决
- Git下的冲突解决
- 盘点互联网招聘玩法:从垂直招聘到猎头平台到精准匹配
- FTP上传
- ulimit 设置
- WTL 选择文件
- 标签语义化
- windows下git的安装、配置与操作(八)——git冲突的解决
- 存储过程(五)游标
- ubuntu12.10下Discuz!论坛的安装
- 是我老了,还是时代变了
- 最好用Unity3d热更新脚本Scorpio-CSharp介绍
- 基于SSH商场管理系统
- Spring AOP 剖析
- 区间重合判断
- Fragment加载过程分析