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.
Related
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.
I am having an odd issue with GIT.
I have a git repo for a small project I'm working on. There are no remotes, this is just for my own work. Up until a few days ago, my development didn't even warrant any branches.
I have finally needed to make a branch for some experimental code. When I was done, I simply checked-out the master branch to go back to where I was. And this is where problems started.
There are six files that change between the new branch and the master branch. Every time I switch / checkout either branch (switching between the two) most of those six file names change case.
For example, if the file was supposed to be someCode.py:
Sometimes the file name switches to somecode.py (Incorrect)
Sometimes the file name switches to someCode.py (Correct)
It doesn't matter which branch I pick, the result is different every time. And which files end up with which CaSe is different every time.
I suspected the GIT plugin for VSCode I was using (GIT Graph) at first, but it also happens with the included GIT GUI, and even happens if I use "git switch" from the command line.
I read about the core.ignorecase setting; it was set to True. I tried setting it to False and the problem persists.
Does anyone have any ideas what's going on?
Thank you
Details:
GIT 2.30.0.windows.2
Windows 10
Files are on a mapped network drive
File system is NTFS
Natively, Git is case sensitive so you could have two different files named filename.txt and FileName.txt. On some operating systems (e.g. Linux) that works fine, and on others (Windows) it does not. Note the same thing goes for branch names too; you can't have two different branches differing by case only on Windows. The reason for this is branch names are stored as a file on your drive.
Most likely your problem is that the files in question have different names on the two branches, but differ by case only. If so, pick which one you want (perhaps master), and on the other branch rename those files to match the casing exactly. If they are actually supposed to be different files, then change their name by more than just casing.
Another possibility is that two (or more) files with names differing by case only exist in the same branch, and switching branches simply causes the issue to come to light. Note it could be the files themselves, or it can be any of the directories in the path to those files could have different casing too. To determine whether this is the problem, navigate to the root of your repo in Git Bash and run this command:
git ls-tree -r HEAD | grep -i [filename-without-path]
If you see two or more files with the same name but different casing, you've identified the problem.
It seems I have resolved the issue - at least to a point.
I created a new branch, manually fixed the file names in Windows Explorer. Now, switching between master and the newBranch does things as expected.
However, if I ever switch to the firstBranch from the question, the issue resurfaces. There seems to be an issue with that branch, and switching in and out of that branch causes the issue.
I still do not have an answer as to why.
EDIT: OK, maybe not. Repo seems to be having this problem again with other branches.
I have shelved my changes in TFS which will be checked in few days time. Now i want to work on different TFS card which belongs to same file. How can i work on the same file when its changes are not checked in yet ?
How can i work on the same file when its changes are not checked in yet ?
You should use Branch. You can create a new branch based on file are not checked in, then you work on different TFS card with previous branch, after that, you can check out the new branch to work on the same file when its changes are not checked in.
Shelvesets are per-user and differently stored in the source control - it is not possible to merge shelvesets, there's no history etc. The only action possible is unshelving; you cannot even merge files while doing so. So, we only use it as a temporary storage for things that are not finished yet and thus cannot be checked into a branch.
So, you should use branches. Maybe a Main branch and different development branches for features & bug fix.
Hope this helps.
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.
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