博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
处理git pull冲突
阅读量:4148 次
发布时间:2019-05-25

本文共 2042 字,大约阅读时间需要 6 分钟。

git pull同步远程仓修改到本地仓;

当远程仓的有人提交的修改和本地修改的是同一行时,git可能不知道应该保留哪个修改而产生冲突。
实例演示:
1.修改github上面的test.sh,在world后加!并commit.
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
2.修改本地仓的test.sh
比如远程仓有人提交的bs.html和我本地仓commit的bs.html修改存在冲突,这时执行git pull会产生冲突

[root@CSDN /home/Sudley/github/git_learning]#vi test.sh[root@CSDN /home/Sudley/github/git_learning]#git commit -am "change hello to Hello"[main f6f6114] change hello to Hello 1 file changed, 1 insertion(+), 1 deletion(-)[root@CSDN /home/Sudley/github/git_learning]#git pullremote: Enumerating objects: 5, done.remote: Counting objects: 100% (5/5), done.remote: Compressing objects: 100% (2/2), done.remote: Total 3 (delta 0), reused 0 (delta 0), pack-reused 0Unpacking objects: 100% (3/3), done.From https://github.com/Sudley/git_learning   d38ce8e..e8af234  main       -> origin/mainAuto-merging test.shCONFLICT (content): Merge conflict in test.shAutomatic merge failed; fix conflicts and then commit the result.[root@CSDN /home/Sudley/github/git_learning]#

3.处理冲突

打开test.sh文件发现git标记了冲突位置

[root@CSDN /home/Sudley/github/git_learning]#vi test.sh<<<<<<< HEADecho "Hello world"=======echo "hello world!">>>>>>> e8af2340bcfcdef0a0a35b06a70ff9b8bf470c1c

修改后提交

[root@CSDN /home/Sudley/github/git_learning]#cat test.shecho "Hello world!"[root@CSDN /home/Sudley/github/git_learning]#git status# On branch main# Your branch and 'origin/main' have diverged,# and have 1 and 1 different commit each, respectively.#   (use "git pull" to merge the remote branch into yours)## You have unmerged paths.#   (fix conflicts and run "git commit")    #存在冲突## Unmerged paths:#   (use "git add 
..." to mark resolution)## both modified: test.shno changes added to commit (use "git add" and/or "git commit -a")[root@CSDN /home/Sudley/github/git_learning]#git commit -am "fix merge conflicts"[main ddfc0b1] fix merge conflicts[root@CSDN /home/Sudley/github/git_learning]#git status #处理完冲突后# On branch main# Your branch is ahead of 'origin/main' by 2 commits.# (use "git push" to publish your local commits)#[root@CSDN /home/Sudley/github/git_learning]#

转载地址:http://jyiti.baihongyu.com/

你可能感兴趣的文章
使用gdb调试多进程与多线程程序
查看>>
linux:进程组&作业&会话—concept&distinction&contact
查看>>
linux:终端(Terminal)基本概念&终端登录过程详解
查看>>
linux:守护进程&模拟实现mydaemon
查看>>
linux:作业控制&作业规划进程crond
查看>>
用arp.sh脚本文件抓取局域网内所有主机的IP和MAC地址
查看>>
MAC协议之CRC校验码
查看>>
NAT&代理服务器技术调研
查看>>
XShell初体验—连接VMware虚拟机
查看>>
网络端口服务(PortsService)介绍
查看>>
IO概念&5种IO模型介绍
查看>>
socketpair创建双向pipe
查看>>
linux:文件描述符重定向dup&dup2
查看>>
小白的福音—秒懂UDP协议&TCP协议
查看>>
详解TCP协议中控制位及URG&PSH的区别
查看>>
总结TCP协议中的定时器
查看>>
图解TCP—3次握手&4次挥手
查看>>
I/O多路转接之poll
查看>>
C++程序—逗你玩
查看>>
vim多行注释与取消
查看>>