本地develep 分支 。
新建一个分支(iss53)并且切换到这个分支。
git checkout -b iss53
如果需要切回分支master,需要把在iss53上的所有修改都提交了。
git checkout master
主分支一个新的文件出了问题,需要处理。
切回主分支后,重新创建一个分支。hotfix
git checkout -b hotfix
对文件进行了一些修改,然后提交
vim index.html
git commit -a -m "added a new footer [issue 53]"
文件修改结束,
git checkout master/develop
git merge hotfix #快进
git branch -d hotfix #已经合并到主分支上了。不需要hotfix了。
git checkout iss53 重新切回iss53,在iss53上继续工作。
热分支问题
git checkout master 切换回主分支.
git merge iss53
git branch -d iss53
如果两个人都修改的同一个地方,
遇到冲突怎么解决?
$ git merge iss53
Auto-merging index.html
CONFLICT (content): Merge conflict in index.html
Automatic merge failed; fix conflicts and then commit the result.
用git status查看一下
$ git status
On branch master
You have unmerged paths.
(fix conflicts and run "git commit")
Unmerged paths:
(use "git add <file>..." to mark resolution)
both modified:
index.html
no changes added to commit (use "git add" and/or "git commit -a")
# 必须选择其中一种
<<<<<<< HEAD:index.html
<div id="footer">contact : email.support@github.com</div>
=======
<div id="footer">
please contact us at support@github.com
</div>
>>>>>>> iss53:index.html
可以使用图形化工具来解决冲突,可以运行git mergetool.
解决完冲突之后,可以再使用git status查看一下状态,
参考
Pro Git 第二版