首页 / GIT / git上传(本地和远程有冲突时)
git上传(本地和远程有冲突时)
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了git上传(本地和远程有冲突时),小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含3428字,纯文字阅读大概需要5分钟。
内容图文
一. 冲突的产生:在上次git同步(上传)之后,本地和远程均有更改
二. 处理
1. 丢弃本地,采用远程:
git checkout 冲突文件及其路径
如: git checkout bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp
2. 人为合并( git mergetool)本地和远程代码 (思路:先提交没有冲突的部分,再人为合并,再提交冲突的部分,最后将所有改动push上去)
1). git pull: 提示冲突
2). 提交(git add --all; git commit)
3). git pull
4). git mergetool
5). git pull
6). git commit
[216-fixed-area-walk d228a46] Merge branch ‘216-fixed-area-walk‘ of 192.168.1.51:IGV/IGV01-SW into 216-fixed-area-walk
7). git add --all
8). git commit
9). git push origin 216-fixed-area-walk
以下是一次情况2的实际操作过程:
wang@wang:~/IGV01-SW$ git pull
Updating 502a546..9d49eeb
error: Your local changes to the following files would be overwritten by merge:
bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp
Please, commit your changes or stash them before you can merge.
Aborting
wang@wang:~/IGV01-SW$ git add --all
wang@wang:~/IGV01-SW$ git commit
[216-fixed-area-walk c8fd2d7] 添加可行区域请求程序
16 files changed, 167 insertions(+), 22 deletions(-)
create mode 100644 bzrobot_atom_tasks/bzrobot_require_access_area/CMakeLists.txt
create mode 100644 bzrobot_atom_tasks/bzrobot_require_access_area/include/bzrobot_require_access_area/require_access_area.h
create mode 100644 bzrobot_atom_tasks/bzrobot_require_access_area/launch/bzrobot_require_access_area.launch
create mode 100644 bzrobot_atom_tasks/bzrobot_require_access_area/package.xml
create mode 100644 bzrobot_atom_tasks/bzrobot_require_access_area/src/require_access_area.cpp
wang@wang:~/IGV01-SW$ git pull
Auto-merging bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp
CONFLICT (content): Merge conflict in bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp
Automatic merge failed; fix conflicts and then commit the result.
wang@wang:~/IGV01-SW$ git mergetool
This message is displayed because ‘merge.tool‘ is not configured.
See ‘git mergetool --tool-help‘ or ‘git help config‘ for more details.
‘git mergetool‘ will now attempt to use one of the following tools:
meld opendiff kdiff3 tkdiff xxdiff tortoisemerge gvimdiff diffuse diffmerge ecmerge p4merge araxis bc3 codecompare emerge vimdiff
Merging:
bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp
Normal merge conflict for ‘bzrobot_navigation_meta_packages/map_server/src/access_map_server.cpp‘:
{local}: modified file
{remote}: modified file
Hit return to start merge resolution tool (meld):
wang@wang:~/IGV01-SW$ git pull
You have not concluded your merge (MERGE_HEAD exists).
Please, commit your changes before you can merge.
wang@wang:~/IGV01-SW$ git commit
[216-fixed-area-walk d228a46] Merge branch ‘216-fixed-area-walk‘ of 192.168.1.51:IGV/IGV01-SW into 216-fixed-area-walk
wang@wang:~/IGV01-SW$ git pull
Already up-to-date.
wang@wang:~/IGV01-SW$ git add --all
wang@wang:~/IGV01-SW$ git commit
[216-fixed-area-walk 44a25ff] 修改类命名
4 files changed, 15 insertions(+), 14 deletions(-)
wang@wang:~/IGV01-SW$ git push origin 216-fixed-area-walk
Counting objects: 186, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (62/62), done.
Writing objects: 100% (70/70), 6.38 KiB | 0 bytes/s, done.
Total 70 (delta 42), reused 0 (delta 0)
To git@192.168.1.51:IGV/IGV01-SW.git
9d49eeb..44a25ff 216-fixed-area-walk -> 216-fixed-area-walk
三. 从216分支上传更新至216分支的一般操作过程
1. git pull
2. git add --all
3. git commit
4. git push origin 216-fixed-area-walk
原文:http://www.cnblogs.com/cj2014/p/5557654.html
内容总结
以上是互联网集市为您收集整理的git上传(本地和远程有冲突时)全部内容,希望文章能够帮你解决git上传(本地和远程有冲突时)所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。