标签:
创建新分支,commit后;切换回master分支,再次commit;Git此时无法快速合并。
可以git status找到冲突的文件readme.txt, 查看并修改,然后再次提交
1.创建新分支feature1,新增readme.txt的内容,然后add和commit
git checkout -b feature1
修改readme.txt最后一行,改为:
Creating a new branch is quick AND simple.
git add readme.txt
git commit -m "AND simple"
2.切换回master分支,新增readme.txt的内容,然后add和commit
git checkout master
修改readme.txt最后一行,改为:
Creating a new branch is quick & simple.
git add readme.txt
git commit -m "& simple"
3.合并出错
git merge feature1
冲突
git status也可以告诉我们冲突的文件
4.修改
查看readme.txt
Git is a distributed version control system.
Git is free software distributed under the GPL.
Git has a mutable index called stage.
Git tracks changes of files.
<<<<<<< HEAD
Creating a new branch is quick & simple.
=======
Creating a new branch is quick AND simple.
>>>>>>> feature1
Git用<<<<<<<,=======,>>>>>>>标记出不同分支的内容,
我们修改如下后保存:
Creating a new branch is quick and simple.
5.提交
git add readme.txt
git commit -m "conflict fixed"
6.用git log --graph命令可以看到分支合并图
用带参数的git log也可以看到分支的合并情况:
git log --graph --pretty=oneline --abbrev-commit
7.删除feature1分支
删除feature1分支:
git branch -d feature1
标签:
原文地址:http://www.cnblogs.com/lao-wan/p/5127183.html