我已经从 GitHub 上提取了文件。现在我需要创建合并冲突。
如何在 GitHub 上故意制造合并冲突?
编辑两个分支中的同一行,并尝试合并
当合并之前在同一行或文件的相同内容中更改两个分支时,会发生 git 中的合并冲突。如果你只是扩展一个文件或附加一些东西,git 通常会自己解决。
使用此代码:
#!/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
脚本来自:https://jonathanmh.com/how-to-create-a-git-merge-conflict/ https://jonathanmh.com/how-to-create-a-git-merge-conflict/
标题学分:Alexander O'Mara
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)