Failed Xcode Git Merge is stuck

感情迁移 提交于 2019-12-31 18:56:37

问题


We have a git based project with a friend and one master branch. He made some changes to some files, I made changes to some other files, and we may, most probably did, make changes to a couple of the same files. He committed and pushed all of his changes to the repo. Then I went and committed my changes and tried to pull his changes. I was presented with a few conflicts which I mostly resolved in favor of his changes because they were files I did not change. Then when I tried to push, I got a fatal: cannot do a partial commit during a merge.

These are the screens I get.

What can I do? The project runs fine except that the main menu of the game isn't showing the images its supposed to, which are the ones he was working on and the class files he worked on, aside from a couple of other ones.


回答1:


This is a common frustrating situation:

  1. Open the terminal
  2. Go to your project repository folder (the one containing the .git hidden file)
  3. Move your merge head aside typing mv .git/MERGE_HEAD .git/MERGE_HEAD_STUCK

Your problem should be half solved already, in some case you need to make a pull from the organizer:

  1. Open the Organizer - Repositories "File > source control > repositories…"
  2. Find the repository of your project and make a pull from here.

Then you should be able to use Git again from Xcode, you will probably have to resolve some merge conflicts but at least this will be under Xcode and not on the terminal.

Note: Consider removing the .DS_Stores from your git repository




回答2:


You can't commit until all merge conflicts are resolved. Based on what you described there are files that you both changed. They are conflicts that you must resolve.

I've never resolved a conflict in Xcode. You could always resolve the conflict from the Terminal app. Once in a terminal and assuming you've installed the Xcode command line tools try:

git mergetool
git commit

This will/should pop up a FileMerge window that allows you to select your or his edit. The other option you have from the Terminal is to resolve the conflicts by simply accepting his changes. This will break your code but you can go back and fix it. For that try:

git status
git checkout --theirs -- /path/to/a/conflicted/file ...
git add -- /path/to/a/conflicted/file ...
git commit

Then edit the files to fix your functionality. Once all the conflicts are resolved you will be able to commit back in Xcode.




回答3:


Open terminal and make use of the following:

To find which files has conflicts: git status

To do merge and fix conflicts git mergetool

You may need to add some untracked files: git add .

Finally commit changes git commit




回答4:


When I have issues with XCode I simply revert to AppCode (trial version if you have to), and doing a commit from the top-level project folder.

AppCode detects the merge scenario, and sorts out the issue with partial Merge. Similarly if AppCode can't sort it out, I use the Github Desktop. Only if all this fails I'll revert to low level commands.




回答5:


Xcode has issues with xcuserdata files and I had to discard changes and recommitt




回答6:


I solved this with a completely different approach, using only Xcode's Source Control.

Background: Another team Pushed changes to the remote Git repository (via Beanstalk). On my end, the .xcodeproj files came in under different directory, and the changes didn't take. Later, when I tried to commit, I received a Tree Conflict error in Xcode.
Tree Conflict Screenshot

Being nearly impossible to correct using Xcode, I replaced the .xcodeproj file with a downloaded version from the Git server. The result... the Xcode project appeared to clear up, however all the updates from the corrupt Pull were showing up as changes I made and were Staged for a Commit. Look at all these Mods and Added files However when trying to Commit, I received the same "fatal: cannot do a partial commit during a merge" error, discussed here.

Here's how I solved the problem... (Now, understand that I'm a rookie programmer, so I could lack some understanding... but my ignorance led me to find another way to do this.) First, I Cloned my master Branch into a secondary Branch and switched to that branch. Then I created a Working Copy and placed the directory to that working copy outside of the original project directory. (I don't know if this was necessary, but its what I did as I read other troubleshooting techniques.) Then I switched branches to the master, where I realized all my Staged files (changes to Commit) were gone. To make sure all the files were updated to the latest changes made by the other party, I created a new branch called ThirdBranch, which duplicated all files, Pushed it to the Git Server and let Beanstalk compare my server version of the master branch to the ThirdBrach branch I just Pushed (line by line), and all the changes by the other party were present on my Xcode. This meant that my master repository and the Git master repository were the same, which verifies that I solved the problem using Xcode, only.

Don't ask me how, beyond what I just described... and certainly fill in the gaps I left out. I'm new at this and I don't understand everything. Maybe an experienced programmer can separate the irrelevant info from the relevant and recreate this technique more clearly, which is in part why I'm posting this.



来源:https://stackoverflow.com/questions/10568405/failed-xcode-git-merge-is-stuck

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!