Extra branch displayed in Xcode Source Control Pane - xcode

Weird issue here. I merged two branches with different feature sets. I branched from one of the two then merged in the second (using command line). Now in Xcode's source control pane it shows two different branches as current. It's not a big deal but I would like to know how to get rid of the top one (at the very least) and preferably to understand why both would be displayed as current. It makes pushing to remotes a bit of a headache because they have the same app name and so I need to make sure I don't push to the wrong branch. I don't particularly want to have to redo things a different way since the branches had a fair number of merge conflicts.

Figured it out... There were two files that were pointing to the other branch folders in the pbxproj file. This appears to have happened when I merged. Removing the references to these files and pointing to the files in the correct project folder then committing and pushing made the extra branches go away.

Related

How to compare branches in xcode

I am using xcode and its source controler.
I would like to compare two branches I made.
Impossible to do so by using the comparison mode. When I do it, it splits the editor in two (that is right) but I cannot put on branches on one side and the other one on the other side.
Any help?
All the best
Yes you can compare file wise, just go to that specific file where you want to see modified changes by other branch.
Then you will see following bar in editor
on left side, select your own branch and on right side, select branch which has done modifications.
Then you can compare by commits, listed time wise just beside branch name.
In Xcode 12 you choose View->Show Code Review. You'll have two windows, one with the most current edits ("Local Revision") and the other lets you choose from various prior commits.
Assuming you already pulled both branches and now you're watching a feature branch, run
git reset develop
where develop is the other branch to compare.
After that all the modified files and folders are marked in the file inspector.
Next, you can simply use Xcode file comparision:
I don't think this is available yet (Xcode 11). The best you can do is compare individual commits or if you know which files were changed, you can compare individual file changes for those commits.
In XCode 11.x you have to press the two arrows, located on the top right.

Git is seeing changes I didn't make in xcode

I'm programming in xcode (actually Phone Gap in conjunction with xcode) with git. I'm having a strange issue. When I create two identical branches and try to check out back and fourth between them with out making any changes git is telling me that I need to commit because a change has been made (this same thing is also resulting in merge conflicts). It says the changed file is:
platforms/ios/Butterfli.xcodeproj/project.xcworkspace/xcuserdata/benpearce.xcuserdatad/UserInterfaceState.xcuserstate
Can anyone explain what's going on and how to deal with it.
Yes, .xcworkspaces are simply files that Xcode uses to describe the workspace or projects.
IMHO, There's no need to check these files in at all, unless you share settings with other folks in your projects (and in your case, I suppose other machines that have a user named "benpearce").
In fact, you can safely add them to your .gitignore file.
More info can be seen here

Anyone have a method for moving files around keeping Xcode project and git in sync?

I have a large (hundreds of files), horribly disorganized (on the file system that is) Xcode project. I want to move a bunch of files into different folders. I want git to track the move operations, and I want my Xcode project to track the moves as well (just keeping the references intact is enough; I don't need Xcode to rearrange its internal group structure, etc.)
If I drag things around in the Finder, both Xcode and git are in the dark. I have faith that git will figure things out by content when the time comes, but I also notice that there's a difference in the output of git status between doing a git mv and moving the file in the Finder, then adding the deletion and addition operations separately, so I'm assuming there's some difference (even if that difference doesn't end up getting encoded into the content of the commit.) Xcode, on the other hand, is hopeless in the face of this. (You have to manually re-find every single file.)
If I use git mv from the command line, git tracks the move, but I still have to manually reconnect each reference in Xcode (or tear them all out and reimport everything, which is a pain in the ass because many of these files have custom build flags associated with them.)
It appears that there simply isn't a way to cause a file system move from within Xcode.
I've found zerg-xcode and a plug-in for it that claims to sync the file system to mirror the Xcode group structure, but I've not been able to google up anything that goes the other way. I just want a way to move files on the file system and have the two other things (git and Xcode) to keep track of the files across the moves. Is this too much to ask? So far it seems the answer is, "yes".
Yes, I've seen Moving Files into a Real Folder in Xcode I'm asking whether someone's written a script or something that makes this less painful.
Actually, by design, Git doesn't track moves. Git is only about content. If any Git tool tells you there was a move (like git log --follow, it's something that was guessed from content, not from metadata).
So you won't lose information if you move files around with another tool then git add the whole folder.

View two different files on two different branches in Xcode?

How is it possible to view two different files on two different git branches in Xcode? I have renamed one of my class and also added new logic to it. And now I would like to see together the two file in the left and right panel. Meantime I created and checked out a new branch and committed changes.
No, this isn't possible, but there are ways of getting the file's contents using the git command line. See the following SO questions:
View a file in a different Git branch without changing branches.
How to get just one file from another branch.

How to Merge Select TFS Changesets into My Workspace without All Previous Changesets Included

I am working on a project with another developer. We are in the process of a major upgrade with lots of breaking changes. The software we are working on is an AddOn to a product, and we are upgrading to work with a new version of the product. He has checked in some breaking changes that will not run in my environment yet because I am still running on the old version of the product. I have checked in some changes on top of those. Is there any way I can retrieve the code such that it includes only the changes up to the point before the breaking changes and also include only my changes after that in my workspace?
If I had not done a "get latest" I would be OK now because I made the changes on my machine so I would have them. But now I need to "get specific version" to take me back before all the breaking changes and somehow merge only my changesets into my workspace. But there seems to be no way to merge changesets into a workspace, only into another tree. I could select only the files that I touched and get the latest versions of those files, but some of the files contain changes from both my changesets and his changesets (and mine are after his).
So what I really want is a way to merge specific changesets into my workspace (without pciking up all the previous changes) to get back to the state I was in before I did "Get Latest". Is there any way to do that?
Looks like there's no good way to do this. Fortunately, I had another branch that represented the changes I wanted (I had only merged my changes I wanted into it). It didn't feel right to just copy the whole tree over my working tree, so I used WinMerge to identify the files that were different and copied just those files over (after a cursory look to confirm that it was a file that included my changes -- there were a few files generated by Visual Studio that were different just because they were in a different path).
So I guess the general solution would be to create a branch in TFS, merge everything you want into it, get a local copy, then copy the results into your workspace. That does leave a mess in TFS, though (how do you completely remove the dummy branch?) Fortunately the branch I had was one we really wanted to keep (we have a build branch separate from teh development branch).
I'm not really sure if this answers your question, but if you select "Get Specific Version..." then you can select a specific changeset.

Resources