Xcode source control not showing current branch changes - xcode

I am running Xcode 8.2.1, and am using github version control. Normally, I am able to press Source Control in the top bar, and then Commit. This menu usually shows all of the files I have changed on the local branch, and I can click through the files and see the local diff. When I run "git status" in the terminal, the modified files show up. Are there any ways that this could be unlinked from my source control? I have set my Source Control preferences to Enabled, and have all of the options selected except "Show Git merge commits in history"

No, you can’t unlink terminal from xcode.
In xcode, what you did is based on local working copies. And the git commands you used in terminal is also based on local git repo. So git status from xcode and terminal should always be synchronized.
If you want xcode to show which files are changed before you use source control -> commit to find the changed files, there is no good ways on xcode. You can use the command git status you find these files.
Or you can feedback this request here, such as change the icon to red check mark if the file is changed (no changed files with blue lock icon).

Related

Xcode source control issue (All projects are already under source control)

The last 5 or 10 sessions, whenever I go to start source control (Source Control > Create Working Copy), I'm prompted by a message "All projects are already under source control." For each of these projects that this message popped up on, I went to the directory of the session in Terminal and ran ls -a to check for hidden files and see if .git files really existed. I did this in the directory the Xcode sessions are located and went back one folder at a time, checking each folder for .git files as well, but none of the parent directories have .git files either. The only way I can get Xcode to start source control is if I use terminal to make the first git commit:
git init git add . git commit -m "Initial Commit." This never used to happen before, I used to always be able to start source control through Xcode.
Then I can use Xcode source control after.
Anyone know of a fix?
On OS 10.12.3 and Xcode 8.2.1
I wrote a solve in the form of articles at a similar issue.
https://stackoverflow.com/a/50751648/2036103
hope will help someone.
The message All projects are already under source control, means the project has already controled by git (.git folder in the same path or as the parent path of the). So what you need to do for the project in xcode is to commit/pull/push. Or you can config the project by source control -> project (usually above create working copy item) -> configure git.
If you want add a file in the same git repo, you should add a file in the path same as .git or it's sub-path, then in xcode -> source control -> commit -> select the file you added -> commit.
If you want to do source control for another project, you should close the current project, and then reopen xcode with another project.

Git version control history "modifed files" are empty in Xcode 8.1

When I click "show modified files" in my Git History
I see empty window with message "No version Editor"
I noticed, that If I commit some files and doesn't restart XCode, history of that commit will show modified files well. But after Xcode restart it becomes empty too.
My settings:
XCode 8.1
Console git commangs like git log -p, work fine.
How can I reattach repository to my project to reset it?
I have no repositories in my accounts settings:
Yes, it’s the bug for xcode to show modified files in version control history. You can vote your voice in Apple bug reporting

How can I checkout github project on xCode 5 correctly?

How can I checkout github project on xCode 5 correctly?
I have done checkout from xCode (Source Control - Check Out...). But now I can't commit any changes to the repository (Source Control - Commit...). All "Source Control" commands are disabled on the xCode except "Check Out...". But ".git" folder presents on the project's folder. What's wrong with it?
You can follow this tutorial, which describes your case after having created locally a git repo and done some commits:
The git repository is ready, but if you go back to Xcode and open the Source Control menu, you’ll find out that everything is still disabled.
That’s because Xcode doesn’t get notified automatically about our manual git repository addition.
So, close Xcode using the menu Xcode > Quit Xcode and re-open it.
Now, in the NoGitExample project if you open the Source Control menu once again, you’ll see that all options have been enabled, just like if we would have added the git repository along with the project creation.

Using Cornerstone, how do I ignore Xcode's UserInterfaceState.xcuserstate file?

I'm using Cornerstone 2.7.12 and Xcode 5.1. Mostly I use Xcode's Source Control menu items but in this particular working copy I'm having trouble with UserInterfaceState.xcuserstate. I can commit just fine. Then, for example, I try to switch branches but Xcode complains that I have uncommitted changes. When I commit, the only thing that's changed is UserInterfaceState.xcuserstate. So I commit. Then I try to switch again but again Xcode complains about uncommitted changes. Again it's UserInterfaceState.xcuserstate.
So I thought I'd do the switch with Cornerstone (right-click on the Working Copy -> Switch...). In Cornerstone I've added *.xcuserstate to the Global Ignores (Cornerstone -> Preferences -> Subversion -> turn off Use default global ignores -> add "*.xcuserstate") but it doesn't ignore it. I've quit and restarted.
Using Cornerstone, how do I ignore Xcode's UserInterfaceState.xcuserstate file?
Here's what I did:
in Terminal cd to the project.workspace directory
svn -v status revealed this file was under version control (M):
M 655 654 user xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
svn delete --keep-local --force xcuserdata/user.xcuserdatad/UserInterfaceState.xcuserstate
That fixed it. At that point Cornerstone showed that it was ignoring the file. And Xcode behaved properly too.

Using Git with an existing Xcode project

I am trying to figure out how to use git in my project workflow, and I have an existing Xcode project that I want to put into the repository. I think I have the repository set up correctly under organizer, but the Source Control menu is grayed out.
Apparently, it's easy to do if you start a new project, but how do I import an existing project with snapshots and everything?
I'm using Xcode 4 and git 1.7.4
Also, if there are any good walkthroughs on git configuration and best practices, that would be nice. I'm a little late to the game, so anything that can get me up to speed would be cool.
GitHub has some very good git tutorials at help.github.com.
to do the initial setup of a repository, open up a terminal window, and CD to the project directory. once there, type
git init
git add .
git commit -m "Initial commit"
Restart Xcode.
The repository should now be set up, and you will be able to manage it in xcode 4.
Xcode 7 (and 8)
If you were starting a new project you would just check Create Git repository during the setup. (Then skip down to the Commit part below.)
But it you are working with an existing project, go to Xcode > Preferences... > Source Control and check the Enable Source Control box.
Then in the main Source Control menu choose Create Working Copy....
(If you get a "Please tell me who you are" error the see this question/answer or one of the other linked questions there.)
When that has finished, make any change to one of your Xcode project files. Then go back to the Source Control menu and choose Commit.
And write a commit message and click the Commit button. (If the commit button is disabled, then make any minor change to your project and try again.)
In Github sign in and create a new repository.
Call it whatever you want, but don't add a README or .gitignore or license yet. You can add those things later. Doing so now will make the syncing more difficult.
Copy the link to your repository.
Go to Source Control > your branch name > Configure.
Click the Remotes tab > "+" button > Add remote....
Enter the github repository name and paste in the address.
After adding the remote, click Push in the Source Control menu. Enter your github user name and password. That's it. You project should be copied to github now.
(I had some trouble getting my username and password accepted at first. If that happens to you go to Xcode > Preferences... > Accounts > your new repository. Enter your user name and password there and then try the Push again.)
You can add a README and other files, but if you do it from the web, you will have to do Source Control > Pull in Xcode before you con commit other changes.
Now any time you make changes in Xcode, all you have to do is Commit and Push.
I learned this method mostly from here.
See also
The Basics of Git and GitHub
How to add a .gitignore file for Swift in Xcode
I just went through the process of doing this for several projects, and ran into some issues. Here was my process, mostly pieced together from the other answers on this page/site. Order is very important here
Open terminal and cd into the directory containing the .xcodeproj file
git init
In finder enter the newly created .git folder (in the same directory as the .xcodeproj file). Find info/exclude, open and add these lines, .DS_Store and xcuserdata/
Not sure if this is needed, but I used terminal to cp info/exclude over to a .gitignore file
git add .
git commit -m "Initial commit"
Now to get XCode to actually see the repo. In the project organizer, you first have to delete the project from the Projects tab. Then simply re-open the project to get it back. This will detect the GIT repository just created
In the repositories tab of the organizer I then branch off the master branch/switch into whatever version I'm working on.
Hopefully this helps someone without being too redundant. What now seems simple was definitely a challenge for someone new to GIT with existing projects
Check out my post on this topic Setting up a git repository in XCode for a pre-existing project. The above is correct, but it will include UserInterfaceState in your changes as you commit and this could be annoying because this file updates everytime you do anything in xcode, even if it is as simple and navigating through files or folders in your project.
if your XCODE 7 is not connecting with existing GIT repository. Try following
xcrun git config --global user.email your#email.com
xcrun git config --global user.name "your name"
Newer versions of Xcode simplify adding git to an existing Xcode project. Open your project in Xcode and choose Source Code > New Git Repositories. A sheet opens.
Select the checkbox next to the project and click the Create button to add git to the project.
Note:Specially for Xcode 11
CD to project directory using terminal
git init
git add .
git commit -m "Initial commit"
After this restart the Xcode and choose Source Control Navigator and then select the master and right click then choose option "Create Remote"

Resources