Xcode Source control commit winow showing no files - xcode

I created a new project and try to commit it from source control tab. But the commit widow does not show any files.

It is possible that your project is not being tracked by git. To enable tracking, you need to open the project directory in command prompt and run following command -
git init
This will initialise git in your project repo and start tracking your files.

Related

Xcode's "branches" master is an incorrect project

I want to put my current project on GitHub, but within my Source Control Navigator, it shows Branches. After double clicking the Initial Commit within master, it's showing a different project than what is currently open on Xcode.
Eventually I want to put the Xcode project on GitHub, but even if I try, it puts whatever is in master, which is incorrect. How do I fix this?
Edit:
It took a few Terminal commands, and then I was able to go to the Source Control menu >> Commit without errors.
xcrun git config --global user.email you#whatever.com
xcrun git config --global user.name "Your Name"
This put the correct version of the project on GitHub after I created a remove. Unfortunately, my master(current) is still incorrect and it includes that on GitHub for some reason.
Here are some screenshots of my Source Control Navigator. I only want first master displayed in the root folder or remote >> origin. Within the Branches folder, the only master shown is incorrect.
I moved a hidden ".git" (system) folder outside my main project folder. I then could create a new repository within the Source Control Navigator, create a new remote and the appropriate projects are visible in GitHub.

Create git repository for existing project?

After a close call with deleting a swift file, I noticed that I did not have create the project with it to create a git repository. Is there a way to have an existing project start a git repository? Or do I have to start a new project and move all of my code/files over?
Yes, you can initiate a git repo for an existing project.
There are several ways to initiate and manage a Git repository over an existing project.
Preparations.
There are some files that are not subject to source control. Those are project files from your IDE, compiled classes and so on. To exclude them, get a .gitignore file and put it to the root directory of your project.
Creating a Git repo with command-line tool
go inside the project folder and create new git repository using:
cd path/to/your/project
git init
Then add your files
git add *
and then commit
git commit -am "Initial commit"
if you need to push it to GitHub/BitBucket use
git remote add origin [repository URL]
and then
git push origin master
Creating a Git repo with a gui-based tool or IDE.
You can as well use any gui-based tool. E.g., in IntelliJ IDEA use the menu [VCS] - [Import into version control] - [Create Git repository].
If you are going to use GitHub, there's a convenient GitHub client.

Xcode crashes when working with repository

I have an Xcode project one local and one remote repository. Firstly, there was a problem in current version and I decided to change local repository's head using terminal. Xcode fetched everything and I continued working on the project. When I decided to commit changes, Xcode gave me an error like this: "error: src refspec (detached from ) does not match any.error: failed to push some refs to [repository address]". After, I decided to create a new remote repository and try to make initial commit of this project. I added remote to Xcode and now it crashes even if I open "remotes" tab. I use bitbucket as my remote repo.
Question: is it possible to fix this, or it is easier to copy all the contents of the project to another one and commit new one? Thanks for replies.
I had the same problem: the local git repo was created from command line (from terminal app) and not from within Xcode, Xcode would crash every time even when clicking on the remote tab. I have a different solution that may be easier:
1)Commit and Push all changes with your current project from your local Xcode-non-compatible repo
2) Re-open Xcode (close it if it's open) and select "Check out an existing project" from Xcode
*If you don't see this Xcode startup screen, go to Source Control->Check Out...
3)Select the remote repo then
4)Select a NEW directory for the checkout destination
Now you will have a project set up and compatible with Xcode!
Solved:
Create new empty project, then copy all the files from previous one. Create new repository, absolutely clean. Push there.
It seems that Xcode had a conflict when local repository's head was changed using command line and git. So, this is as warning for users who got the same situation.

Xcode Git Submodule Commit Issue

What I did
I made a new Single Page App project in my application called "parent".
I made a new Static library project called "child" and I've Added it as a git submodule in my parent project folder.
I have imported the child project into the parent project by dragging from the finder from submodule directory, the child project file to my parent project in Xcode window -> Parent Project file tree.
Now Is my problem
When I would like to do a commit through File -> Source Control -> Commit, I select files enter my message and do a commit all goes right.
Now When I make a change into my child project and try to commit by the same way, xcode make me know it success the commit
Now try a pull from File -> Source Control -> Pull, My child project is selectable but my parent project has "Uncommited Changes".
So I come back to the commit interface and I saw the items that should have been committed during the last commit. Especially the folder of my submodule project.
What I did to resolve the problem
I use git from the command line in my parent project folder:
git add .
git commit -am "Core has been modified"
When I use this, I can access my to repository from the pull interface, that confirm that all change has been committed.
The real Problem
My company would like to make that work only with the Xcode SCM tool.
The problem seems to be linked to the use of "Submodule"
How can I make it work without the use of the Command Line
We have the same problem. It's like a small bug in XCode. Our workaround at the moment is the same as you mentioned and the only solution would be a bugfix or enhancement how XCode support
Our workflow looks like the following :
-commit submodule changes with XCode
-commit main changes with XCode
-commit main directory change with CLI ( git commit )
-push main & submodule with XCode
we hope that this small bug would be fixed in the future directly in XCode
When you make a commit in a submodule, it shows up as a change in the parent.
The solution is to make changes to the submodule first, then commit the changes to the parent. This way all of your changes to the submodule will get bundled into the parent project commit.

Xcode 4: Source Control options grayed out (Git local repository)

When I set up a new project in Xcode 4, and select "Create local git repository for this project," all seems well enough. I'm able to commit files from the Organizer (it would appear.) However, in the Project Manager, the "Source Control" menu options (commit, etc.) are all grayed out, except for "Repositories" which of course just takes me to the organizer.
Furthermore, in the Project Manager window, I don't see any icons by file names indicating if they're changed, committed etc. like I see in the screenshots in the Xcode 4 documentation.
I've tried this with both a project that's connected to Github, and one that's just using a local repository, and I've still yet to see those options not be grayed out. Any suggestions?
I discovered the cause of this problem is that I was saving projects in /Developer.
Turns out, that's a big no-no. Not only does it break git integration in the way described in the original question, as well as breaking other features such as Xcode 4's refactoring functionality, it also runs the risk of deleting all of your work when you install an update. Once I started saving projects outside of /Developer, all the git functions in Xcode 4 started working as expected.
Bottom line: Don't keep projects in /Developer.
This can be a bit confusing. Apples documentation here:
http://developer.apple.com/library/mac/#documentation/ToolsLanguages/Conceptual/Xcode4UserGuide/SCM/SCM.html
Has a great way to activate the source control via the command line:
To set up a Git repository from the command line . . .
Use the cd command to switch to your project folder, making it the current working directory.
Enter git init to create an empty repository.
Enter git add . to copy your project files into the repository.
Enter git commit -m "Initial commit." to commit all the files.

Resources