How to update Xcode git mark UI? - xcode

Xcode has git marks on editing files. It is obvious to know which file has changed.
While I git committed, and the git mark UI still stays same.
➜ musicSheet git:(lu_yin) gst
On branch lu_yin
Your branch is up to date with 'origin/lu_yin'.
nothing to commit, working tree clean
So is it a way to update Xcode git mark UI manually?

The Source Control menu in Xcode has a menu item to refresh the source control status. In Xcode 11 choose Source Control > Fetch and Refresh Status. The menu item name may be different in earlier Xcode versions.

Related

xcode source control doesn't show current branch

I'm using the standard xcode source control (version 9.3)
I just reopened my project and when I go to the Source Control Navigator:
It shows a long hex string at the top instead of the current branch name
None of the branches have '(current)' next to them
I have tried cleaning the project and also closing and re-opening.
Source Control->Commit brings up the standard commit interface with the option to leave a comment.
When I click on the very top row (with blue icon) I can see the new commits but they don't show in any of the branches.
What am I doing wrong?
This worked for me:
I clicked on the row with the long hex name. This brought up the version history for the current version.
I right-clicked the most recent change in the change history.
I clicked 'Branch from...' and created a new branch from that point.
For those wondering how something like this could have happened, it is caused when you checkout a commit rather than checkout a branch. Even if you checkout a commit inside the branch that is "current" (even the most recent commit), this will cause the branch to no longer have the "current" written next to it. So when you are sure that this previous commit that you have now checked out is the commit you want to work with, then you must do what Derek posted to do which is to "Branch from..." to make a temporary branch and then merge this temporary branch into the branch that this previous commit originally came from. And then you can delete the temporary branch. It is somewhat of a pain, but a good reason why Xcode does this is so that you are well aware that you are on a previous commit and that you should really make sure this previous commit is what you want your current branch to be at.

How to remove an unused GIT branch in Xcode?

I can see how to create a branch, but I would like to remove one that I will never use. There doesn't seem to be such functionality in Xcode, so I tried in terminal doing
git branch -d BugFixes
but no luck.
You can delete git branches in Xcode. Choose Source Control > WorkingCopy > Configure WorkingCopy, where WorkingCopy is the name of your working copy, which is usually the name of your project. A sheet opens. Click the Branches button at the top of the sheet. Select a branch and click the minus button at the bottom to remove the branch. Note that Xcode does not let you remove the current branch.
Xcode 9 Update
Apple moved the user interface for branches to the source control navigator in Xcode 9.
To delete a branch, select it, right-click, and choose Delete. You cannot delete the current branch.
please try:
for local: git branch -D BugFixes
for remote: git push origin :BugFixes

Why aren't my commits showing up in Xcode 4?

I am a new programmer and trying to use Xcode's source control manager to keep track of changes to my code.
Right now I would like to revert back to a previously committed version of my project. However, in opening the Organizer, selecting Repositories, and selecting my project from the left project list, I can only see snapshots of my project.
The previously committed versions appear correctly when using the Version editor outside of Organizer.
Ideas?
I don't believe you can do this within Xcode but it is simple enough outside of Xcode. The easiest approach would be enter the following in Terminal:
git checkout -b <new branch> <commit>
This won't revert on the current branch but will give you a new branch to develop off of. If you really want to revert then simply:
git revert <commit>
with conflict resolution will work.
If you can't find 'git' within the Terminal then 1) install the Xcode command line tools or 2) look in the Xcode package under Xcode/.../usr/bin to find it.

Can't commit changes to local git repository

I have created a new project and checked the "create a local git repository" option. I opened the organizer to check that there is a repository for my project and it was there. I made some changes on some files, and noticed the source control specific letters "A" .. "M" beside them, but when I choose: File-> Source Control -> Commit, I get the following message from XCode 4.2:
the operation could not be performed because no valid working copies were found
Please verify that your files are under source control and try again
However, I opened the organizer again, and noticed that the repository of my project includes three icons on the left bar: Branches, Remotes and a folder with the same name as of the project. I chose the last one (the folder) and pressed the Commit button on the bottom bar of the organizer. The commit sheet opened and I performed the commit successfully. Now, when I close the organizer, and edit some files in my project, I do not see the source control specific letters "M" ... "A" ... beside each modified file.
My problem is about two points:
1) Why can't I commit from File->Source Control->Commit menu option
2) When I commit from the repository itself, and go back to the project and edit some files, why do not I see source control letters beside modified files?]
For what it's worth (and as #Jahelia's comment mentions), this seems to be a bug in XCode 4.2 when it first engages with git. The workaround seems to be to at least close Xcode and reopen. (If that doesn't work, try opening and closing the organizer.)
I encountered this myself today when trying out Git with Xcode for the first time. I created two demo projects with the "create a local git repository" option and they had the same problem. I was able to commit from the organizer window, but the main Xcode file view didn't seem to recognize git at all.
After quitting and restarting, I created a third demo with the git option, and the main window recognized the changes (after building) right off the bat - i.e showed the "M" beside a modified file.
I've experienced and recovered from this.
I can't tell you what causes it but, notably, in the "Repositories" view in my Organiser, I had TWO similarly-named repositories. What differed about them was the case of one of the paths.
One was "~/Work/Code/Bumhole" and the other "~/work/Code/Bumhole".
I caused the problem by XCode crashing during a commit to the repository (of many changes).
I fixed the problem by
closing the offending project
closing Xcode
rebooting
reopening Xcode
(close the project if its open)
open the Organiser view
Select the "bad" repository and delete it with backspace
Navigate the remaining "good" repository until you see the .xcodeproj file
Double click the .xcodeproj file to open the project
I expect this list is a superset of the steps needed to fix the problem, but this worked for me.
If your project is in /Developer/.... move it elsewhere and reopen the project. This may resolve your problem.
There seems to be a problem under Xcode 4.2 with projects in /Developer/... and git integration (you get the error "The operation could not be performed because no valid working copies were found. Please verify that your files are under source control and try again")
This bug still exists in Xcode 4.6.3 and when using Subversion.
I know this has already been answered but this worked for me:
Open terminal
cd yourprojectdirectory
git config --global user.email "youremail#email.com"
git config --global user.name "username"

Make Xcode 4 stop auto staging with git

I hate it that whenever I make a change in Xcode 4 it automatically does a "Git add" command. Is there a way to make this stop?
What I do is perform all my git interaction through the command line. Since I can't get Xcode to ignore the fact that my project is under git control, and since therefore I can't get Xcode to stop doing git add for every new file I create, when I get to the command line the first thing I do is git reset to reset the index. This undoes all the annoying git add stuff that Xcode did automatically. Now I'm in charge of what goes into the index and so I get to form my own commits the way I want.
For Xcode 6 this is not an issue anymore. Visit Preferences -> Source Control tab and turn off 'Add and remove files automatically' checkbox
No. Xcode 4's git integration is "broken" in that they tried to present a uniform interface to source control regardless of whether the back-end is git or svn. That means they're supporting only the lowest common denominator of functionality. As a result, use of the index (the "staging area") is out. It always does auto-adds no matter whether you want it to or not.
EDIT: Actually, I don't think it auto-adds. I think it always does commit -a. Looking at git status on the command line shows me many new and modified files that are NOT staged. But I'm sure if I committed with Xcode they'd all end up in that commit.
For me, the solution was this one https://stackoverflow.com/a/6378745/1078859
TL;DR; remove the repository from xcode's organizer
While the question title says XCode 4 this question appears at the top for many search results related to this issue even in newer versions of XCode. Here is an answer that addresses newer versions of XCode. In XCode 6 you can turn off version control by going to XCode --> Preferences --> Source Control Tab and uncheck Enable Source Control.

Resources