Git冲突中git checkout高级用法是什么
发表于:2025-12-03 作者:千家信息网编辑
千家信息网最后更新 2025年12月03日,Git冲突中git checkout高级用法是什么,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。背景Git冲突的原因,一
千家信息网最后更新 2025年12月03日Git冲突中git checkout高级用法是什么
Git冲突中git checkout高级用法是什么,很多新手对此不是很清楚,为了帮助大家解决这个难题,下面小编将为大家详细讲解,有这方面需求的人可以来学习下,希望你能有所收获。
背景
Git冲突的原因,一般是修改了同一个文件导致的,这个文件有可能是别人提交到远程仓库里面,还有就是需要合并这个文件导致的。
解决方法
你确定你需要的是哪个仓库的文件
git checkout --theirs conflicted_file.txt # 保留远端的
git checkout --ours conflicted_file.txt # 保留本地的
然后执行add和commit
git add -A
git commit -m "update conflict
举个栗子
获取远端服务器上的文件,提示冲突了需要合并
# git cherry-pick FETCH_HEAD
* branch refs/changes/85/12385/3 -> FETCH_HEAD
error: 'cherry-pick' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm ' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: cherry-pick failed
查看当前仓库的状态
# git status
Not currently on any branch.
You are currently cherry-picking commit 53e5374.
(fix conflicts and run "git cherry-pick --continue")
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
Unmerged paths:
(use "git add ..." to mark resolution)
both modified: file1.txt
用提示的命令执行
# git cherry-pick --continue
U file1.txt
error: 'commit' is not possible because you have unmerged files.
hint: Fix them up in the work tree,
hint: and then use 'git add/rm ' as
hint: appropriate to mark resolution and make a commit,
hint: or use 'git commit -a'.
fatal: Exiting because of an unresolved conflict.
提示file1.txt有更新,确定替换为远程仓库的文件。这里用theirs
git checkout --theirs file1.txt
然后添加到本地仓库
git add -A
最后继续cherry-pick「复制」
# git cherry-pick --continue
[detached HEAD 8f26ce8] Summary : test git checkout --theirs
Author: Rik
2 files changed, 0 insertions(+), 0 deletions(-)
小结
git ckeckout 和 带参数的--ours和 --theirs还是有区别的。
看完上述内容是否对您有帮助呢?如果还想对相关知识有进一步的了解或阅读更多相关文章,请关注行业资讯频道,感谢您对的支持。
文件
仓库
冲突
提示
帮助
高级
清楚
内容
原因
参数
命令
对此
小结
就是
文章
新手
方法
更多
服务器
状态
数据库的安全要保护哪些东西
数据库安全各自的含义是什么
生产安全数据库录入
数据库的安全性及管理
数据库安全策略包含哪些
海淀数据库安全审计系统
建立农村房屋安全信息数据库
易用的数据库客户端支持安全管理
连接数据库失败ssl安全错误
数据库的锁怎样保障安全
金山区多层软件开发哪家好
网络安全报纸写字的
生活学习中哪些用到数据库
奉贤区项目软件开发服务收费
插入数据库php
远端服务器地址
服务器搬迁时间表
软件开发项目的冲突
如何用云服务器玩剑三
怎么设置服务器
制造企业里的软件开发
伊对服务器
服务器安全狗对dos有用吗
网络安全网络安全背景图片
数据库复合键
数据库中定义模式是指什么
云技术的软件开发
云从科技互联网入职培训计划
中指数据库和克而瑞
欧依安盾软件开发
如何测试服务器网络资源
福建移动云空间部署云服务器
莲湖区系统软件开发
无锡dell服务器维修服务站
ai媒体服务器
网络安全四进活动情况汇报
银河麒麟系统共享服务器连接失败
微信公众平台服务器开发
软件开发行业账务处理科目设置
注意网络安全问题有哪些问题