I want to get rid of the link to the git repository
As you can see below clicking on source control still shows the old git remote.
I was using both SVN and Git, Xcode was configured with GIT.
What I did was
delete .git/ in Terminal.
Delete Git Repositories from XCode preferences
Add SVN Repository to Xcode Preferences.
Check out a new working copy Using Source Control - Checkout
I have tried adding a new git and setting the remote or deleting it.
What I have done is manually edit the files
.xccheckout
.xcscmblueprint
Which were located in .xcworkspace I found these by grepping
grep -wr git *
I deleted every key value which had git in it.
I am not sure whether I left some superfluous data in it, but so far it seems to be holding up.
As you can see the git part is gone and only my svn remains
Related
When I build a project with Xcode, the default git location is fine. I'm able to initiate source control through Xcode like normal. But when I build sessions from other Apps, such as the Projucer, I can't use the custom git location, as it doesn't see all the files. I need to manually create the first git commit in the correct location with:
git init
git add .
git commit -m "First Commit"
After this, Xcode sees the git repo and as is able to take off from there, and I dont have to use command line after that.
My question is, is there a way to set the default location of git within Xcode? Avoiding commands? Also, are there any visual ways to gitignore files through Xcode? Thank you.
As illustrated in Setting up a git repository in XCode for a pre-existing project, you would still still those Git commands.
The "Git Create Project" of XCode 7 and 8 would still create a .git in the default location (<root of the project>/.git)
When I started my project I used Git in the terminal to track changes. Then I realized source control is built into Xcode. So I committed all my changes, everything worked well. Then I went to history in Xcode and saw all my previous commits made from the terminal.
How does Xcode know about those commits? Especially since I haven't signed into my Git repo in Xcode.
The Git history is kept locally in the project's .git folder. When you open Xcode, it finds your local .git folder and uses it to show the project's history.
You don't have to push to your remote Git repo for that, since the history is kept locally.
I am using git in my projects, whenever I try to pull from Xcode I get "Uncommitted Changes" and it prevents me from pulling/pushing.
I try to commit and find one file with extension *.xcuserstate, this file is modified whenever I open/scroll into any project file in Xcode. That leaves me no option but to do a single commit that contains that file, which fill the git commit logs with meaningless commits.
Is this there is a way to stop this behavior?
I tried to put *.xcuserstate and xcuserdata into git ignore but that caused Xcode to crash every time I try to pull.
This happens with Xcode 4.2 and 4.3
Normally you don't want to put the *.xcuserstate and *.xcuserdata files into your Git repository. These files aren't really part of your project, but are just a place where Xcode stores its local information that is helpful when reloading your project.
You can fix this by using:
git rm --cached *.xcuserstate *.xcuserdata
and then committing the result. This will remove those files from the repository without removing them from your working directory.
If this is a settings file which is different for every developer, you probably don't need to version control it, just remove it from Git.
If that is not an option, you can Git Stash Save your changes before pulling and Git Stash pop to apply them again.
in Xcode 4 how to associate a project to the local Git repository I set up?
That is:
I've set up a Git repository after the Xcode 4 project was already created, based on instructions here:
I've gone to Organizer and "added" this as a local Git repository
When I go to my project in Xcode 4 the source code functions still don't appear to work - I'm guessing it because there must be some way of tying the Xcode Project wiht the local repository I created?
From "How to Create Git Repos for Existing Xcode Projects":
UPDATE: Apparently just initializing an empty repository in the project directory is enough; Xcode autodetects it for you.
It be nice if something to that effect was in the documentation. Thanks to Jason for that (details here). Open the project directory in a terminal and type the following:
git init
git add .
git commit -m "Initial commit"
So in your case, it should detect it.
The OP Greg comments:
I found out that all I had to do was change a file, and then the Xcode 4 pop up menu for the file did show a source control set of options (previously greyed out).
So the initial part of the answer is correct re the manual git commands for creating the git repository.
Otherwise you can try:
make a new XCode4 project with a(n empty) git repo in it
move your .git directory and override the Xcode 4 project .git
move the sources in that new Xcode 4 project directory
see if XCode4 then detect your sources and the Git integration
Not your case probably, but one of the comments mentions:
If you're switching from an SVN repository (which I was), the trick is to go into your project folder and delete or rename the .svn directory.
For me it seemed that Xcode would find the .svn folder first (or preferred it, even though the backing repository was decommissioned), but once it was gone Xcode would happily start using the git repository.
That was actually the issue for another Xcode 4 Git user here on SO.
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"