Intentionally create Merge Conflict

六月ゝ 毕业季﹏ 提交于 2021-02-07 14:39:30

问题


I have pulled the files from GitHub already. Now I need to create a merge-conflict.

How do I intentionally create a merge conflict on GitHub?


回答1:


Edit the same line in two branches, and try to merge

Merge conflicts in git happen, when two branches were changed on the same line or in the same content of a file before a merge. If you just extend a file or append something, git usually just figures it out by itself.

Use this code:

#!/bin/bash
mkdir git-repo
cd git-repo
git init
touch my_code.sh
git add my_code.sh
echo "echo Hello" > my_code.sh
git commit -am 'initial'
git checkout -b new_branch
echo "echo \"Hello World\"" > my_code.sh
git commit -am 'first commit on new_branch'
git checkout master
echo "echo \"Hello World!\"" > my_code.sh
git commit -am 'second commit on master'
git merge new_branch

script is from: https://jonathanmh.com/how-to-create-a-git-merge-conflict/

title credits: Alexander O'Mara



来源:https://stackoverflow.com/questions/33454605/intentionally-create-merge-conflict

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!