详情
接上篇文章,更加严谨的来说,再修改时要创建一个新的分支进行修改,修改完成再拉取远端仓库最新版本,再进行合并,有冲突解决冲突,再push,最后在删除开发分支这样一个流程。所以现在就来简单记录分享一下如何解决合并分支冲突。
代码语言:javascript复制# 创建分支 (develop)
git checkout -b dev
# 新分支和本地最新的master分支内容相同,再次进行修改
vim [xxxx.md]
# 在dev分支上add && commit
git add .
git commit -m "commit on dev"
# 切换回master分支并拉去最新代码
git checkout master
git pull origin master
# 合并dev分支至master
git merge dev
# 若无冲突直接push
git push origin master
# 若有冲突直接打开冲突文件解决冲突再次提交推送即可
vim [xxxx.md]
git add .
git commit -m "resolve conflict"
git push origin master
# 删除dev分支
git branch -d dev
以下是例子:
代码语言:javascript复制song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$ git checkout -b dev
Switched to a new branch 'dev'
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (dev)
$ vim index.html
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (dev)
$ git add .
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (dev)
$ git commit -m "zggsongadd3ondev"
[dev 5c28c74] zggsongadd3ondev
1 file changed, 1 insertion( )
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (dev)
$ git checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$ git pull
remote: Counting objects: 5, done.
remote: Compressing objects: 100% (3/3), done.
remote: Total 3 (delta 1), reused 0 (delta 0)
Unpacking objects: 100% (3/3), 293 bytes | 16.00 KiB/s, done.
From ssh://git.zggsong.cn/ksat/Test
cbf451e..294d107 master -> origin/master
Updating cbf451e..294d107
Fast-forward
index.html | 1
1 file changed, 1 insertion( )
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$ git merge dev
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master|MERGING)
$ vim index.html
####### Conflict Content ######
<<<<<<<HEAD
// add by ksat3
=======
// add by zggsong3
>>>>>>> dev
####### Conflict Content ######
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master|MERGING)
$ git add .
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master|MERGING)
$ git commit -m "resolve conflict on zggsong"
[master 03a1211] resolve conflict on zggsong
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$ git push origin master
Enumerating objects: 10, done.
Counting objects: 100% (10/10), done.
Delta compression using up to 8 threads
Compressing objects: 100% (6/6), done.
Writing objects: 100% (6/6), 632 bytes | 632.00 KiB/s, done.
Total 6 (delta 2), reused 0 (delta 0), pack-reused 0
remote: . Processing 1 references
remote: Processed 1 references in total
To ssh://git.zggsong.cn/ksat/Test.git
294d107..03a1211 master -> master
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$ git branch -d dev
Deleted branch dev (was 5c28c74).
song@DESKTOP-JDGUG5G MINGW64 /d/gitR/Test (master)
$
本文作者:ZGGSONG
本文链接:https://cloud.tencent.com/developer/article/2101056
版权声明:本站所有未注明转载的文章均为原创,并采用CC BY-NV-SA 4.0授权协议,转载请注明来源