Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode merging issue

Tags:

git

xcode

I am attempting to merge two branches, but I have four files with a "C" icon at the side of the file name, like the following:

enter image description here

No matter how I click the file, I cannot open it.

Meanwhile, the bottom right "Merge" button is inactive, and I am guessing that the cause for unable to select "Merge" is the icon beside the file name. Can anyone tell me what does that sign mean? And If resolving the problem with the "C" icon is enough to make the "Merge" button active so that I can merge two branches successfully?

After I click on the "C" file, and then click on some other files with A, there is a message says:

The source control operation failed because the file “XXX” could not be found. Make sure a valid file exists in the repository and try again.

I understand that I added some new files that the other branch does not have, so I guess this is the other cause for me not able to merge the two branches? However, I am confused that, if I were to fix the alert and the new file exists in the repository, doesn't it mean that I actually successfully "merge" the two branches, sine the old branch would then contain the new file? Could anyone provide any insight in this?

like image 575
qsmy Avatar asked May 01 '19 09:05

qsmy


1 Answers

https://stackoverflow.com/a/20033446 helped me solve this. There was an untracked file causing the issue. The file was there on both tracks but somehow it wouldn't work.

What I did was the following:

  1. Add the problematic file name to the .gitignore in both repos

  2. Close Xcode

  3. cd into main branch

  4. git rm -r --cached .

  5. open the project, change a file and commit.

  6. Exit Xcode to do git add .

  7. Open Xcode and commit again, push

  8. cd into the problematic branch

  9. git rm -r --cached .

  10. open the project, change a file and commit.

  11. Exit Xcode to do git add .

  12. Open Xcode and commit again, now pull

  13. Do a change, commit and push.

  14. Now in your main, pull once again.

Both dirs are now on the same state. Edit your .gitignore file to add the problematic file back in, push from this dir and pull from the other dir.

Now both have the same clean state with the problem file included.

like image 179
user2161301 Avatar answered Sep 22 '22 09:09

user2161301