Git中的merge命令實現和工作方式
2015年8月17日星期一
丹丹
git代碼在合並兩個分支的時候總是會出現一下的錯誤提示,不能正常的完成合並分支,錯誤提示如圖所示:
但是在其他的終端是可以完成合並任務的,所以是本地iMac的環境問題,推測原因一:.ignore文件的問題,推測原因二:是Xcode的問題。
針對可能原因二:
鏈接:
http://stackoverflow.com/questions/14605231/git-merge-branch-into-master
按照參考文件在終端進行操作,但是仍舊會有這樣的錯誤提示:
QiaoDandandeiMac:teamworkTwo qiaodandan$ git checkout master
M homezxb-3.8.0/homezxb.xcodeproj/project.xcworkspace/xcuserdata/qiaodandan.xcuserdatad/UserInterfaceState.xcuserstate
Already on 'master'
Your branch is up-to-date with 'origin/master'.
QiaoDandandeiMac:teamworkTwo qiaodandan$ git merge Branch1104
Updating 995534b..abd7343
error: Your local changes to the following files would be overwritten by merge:
homezxb-3.8.0/homezxb.xcodeproj/project.xcworkspace/xcuserdata/qiaodandan.xcuserdatad/UserInterfaceState.xcuserstate
Please, commit your changes or stash them before you can merge.
Aborting
QiaoDandandeiMac:teamworkTwo qiaodandan$ git commit -m "提交"
On branch master
Your branch is up-to-date with 'origin/master'.
Changes not staged for commit:
modified: homezxb-3.8.0/homezxb.xcodeproj/project.xcworkspace/xcuserdata/qiaodandan.xcuserdatad/UserInterfaceState.xcuserstate
no changes added to commit
QiaoDandandeiMac:teamworkTwo qiaodandan$ git push
ssh: connect to host 192.168.221.11 port 22: Operation timed out
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
QiaoDandandeiMac:teamworkTwo qiaodandan$ git push
Everything up-to-date
QiaoDandandeiMac:teamworkTwo qiaodandan$ git merge Branch1104
Updating 995534b..abd7343
error: Your local changes to the following files would be overwritten by merge:
homezxb-3.8.0/homezxb.xcodeproj/project.xcworkspace/xcuserdata/qiaodandan.xcuserdatad/UserInterfaceState.xcuserstate
Please, commit your changes or stash them before you can merge.
Aborting
QiaoDandandeiMac:teamworkTwo qiaodandan$
如何解決???
在終端出現的問題,在sourceTree中完美解決,發生沖突之后,在sourceTree中去選項目文件即可完成合並代碼,並且成功提交代碼。體現了sourceTree和終端的完美結合,解決步驟:
在sourceTree中拖拽好本地文件之后,就配置好了sourceTree,這樣就可以這樣解決沖突的工程文件啦。如圖所示: