Git中的merge命令实现中出现问题及其解决

时间:2022-03-02 15:10:12

Git中的merge命令实现和工作方式

2015年8月17日星期一

丹丹

git代码在合并两个分支的时候总是会出现一下的错误提示,不能正常的完成合并分支,错误提示如图所示:

Git中的merge命令实现中出现问题及其解决

但是在其他的终端是可以完成合并任务的,所以是本地iMac的环境问题,推测原因一:.ignore文件的问题,推测原因二:是Xcode的问题。

针对可能原因二:

链接:

http://*.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,这样就可以这样解决冲突的工程文件啦。如图所示:

Git中的merge命令实现中出现问题及其解决