人生不如意之事十之八九,合并分支往往也不是一帆風順的。
首先介紹一下為什么出現(xiàn)沖突:
1:準備新的jian1.0.1分支,繼續(xù)我們的新分支開發(fā):
$git checkout -b jian1.0.1
Switchedto a new branch'jian1.0.1'
2:修改工程中的一行代碼:
Creating anewbranch is quickANDsimple.
3:在分支1.0.1上提交
$ git add readme.txt?
$ gitcommit-m"AND simple"
[feature175a857c]ANDsimple1file changed,1insertion(+),1deletion(-)
4:在切換到主分支
$ git checkout master
Switched to branch 'master'
Your branch is ahead of 'origin/master' by 1commit.
Git還會自動提示我們當前master分支比遠程的master分支要超前1個提交。
在master分支上把readme.txt文件的最后一行改(主分支也做同樣的修改)
Creating anewbranch is quick & simple.
提交:
$git add readme.txt$git commit -m"& simple"[master400b400] & simple1file changed,1insertion(+),1deletion(-)
解決沖突:
cd lijian1.0.1xcodeproj/(lijian代表文件名)
vim project.pbxproj
輸入“/HEAD”查找沖突的地方,解決沖突
git diff project.pbxproj
cd ../
cd lijian
git status
git add lijian.xcodeproj/project.pbxproj
git commit -m "fix chongtu"
git branch
git push origin master
下面推薦一個更全面的廖雪峰的博客:
網站:http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000