当前位置:   article > 正文

CC00008.CloudJenkins——|CI/CD&Git配置.V07|——|Git冲突解决|_jenkins automatic merge failed; fix conflicts and

jenkins automatic merge failed; fix conflicts and then commit the result.
一、Git常用命令——解决冲突
  1. ### --- 创建feature1分支并提交版本
  2. ~~~ 创建feature1分支
  3. [root@server12 shell]# git checkout -b feature1 # 创建新的feature1分支
  1. ### --- 修改内容,修改readme.txt最后一行,改为:
  2. [root@server12 shell]# vim readme.txt
  3. Creating a new branch is quick AND simple.
  1. ### --- 提交分支
  2. [root@server12 shell]# git add readme.txt # 在feature1分支上提交
  3. [root@server12 shell]# git commit -m "AND simple"
  4. [feature1 0c34577] AND simple
  5. 1 file changed, 1 insertion(+)
  6. create mode 100644 readme.txt
二、切换到master分支
  1. ### --- 切换到master分支
  2. [root@server12 shell]# git checkout master # 切换到master分支
  3. Switched to branch 'master'
  1. ### --- 查看分支记录
  2. ~~~ Git还会自动提示我们当前master分支比远程的master分支要超前1个提交。
  3. [root@server12 shell]# git branch
  4. feature1
  5. * master
  1. ### --- 在master分支上把readme.txt文件的最后一行改为:
  2. [root@server12 shell]# vim readme.txt
  3. Creating a new branch is quick & simple.
  1. ### --- 将修改后的分支内容提交
  2. [root@server12 shell]# git add readme.txt
  3. [root@server12 shell]# git commit -m "& simple"
  4. [master b68fcb2] & simple
  5. 1 file changed, 1 insertion(+)
  6. create mode 100644 readme.txt
三、分支合并
  1. ### --- 现在,master分支和feature1分支各自都分别有新的提交
  2. ~~~ 这种情况下,Git无法执行“快速合并”,只能试图把各自的修改合并起来,
  3. ~~~ 但这种合并就可能会有冲突,我们试试看:
  4. ~~~ readme.txt文件存在冲突,必须手动解决冲突后再提交。
  5. git merge feature1 Auto-merging readme.txt CONFLICT (content):
  6. Merge conflict in readme.txt Automatic merge failed;
  7. fix conflicts and then commit the result.
四、解决冲突
  1. ### --- 查看冲突的文件并修改冲突文件
  2. ~~~ Git用<<<<<<<=======>>>>>>>标记出不同分支的内容,我们修改后保存再提交:
  3. [root@server12 shell]# git status # 可以显示冲突的文件;
  4. Git is a distributed version control system.
  5. Git is free software distributed under the GPL.
  6. Git has a mutable index called stage.
  7. Git tracks changes of files.
  8. <<<<<<< HEAD Creating a new branch is quick & simple. ======= Creating a new branch is quick AND simple. >>>>>>> feature1
  1. ### --- 重新提交
  2. [root@server12 shell]# git add readme.txt
  3. [root@server12 shell]# git commit -m "conflict fixed"
  4. [master 59bc1cb] conflict fixed
五、删除feature1分支
  1. ### --- 最后,删除feature1分支:
  2. [root@server12 shell]# git branch -D feature1
  3. Deleted branch feature1 (was 0c34577).
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/492141
推荐阅读
相关标签
  

闽ICP备14008679号