How to create Git repo after creating an Xcode project from the command line?

220 views
Skip to first unread message

WebSteve

unread,
Oct 9, 2012, 5:07:45 PM10/9/12
to phon...@googlegroups.com
We can make a Git repo when starting a project in Xcode 4 by selecting that option at startup. But how do you create a Git AFTER creating an Xcode project via Cordova's command-line implementation? 

Thanks!

Devgeeks

unread,
Oct 9, 2012, 5:55:21 PM10/9/12
to phon...@googlegroups.com
http://learn.github.com/p/setup.html

but the tl;dr version is:

git init

WebSteve

unread,
Oct 9, 2012, 7:07:13 PM10/9/12
to phon...@googlegroups.com
Drat. I was afraid of that. I got "command not found." I'm missing a step somewhere.

Devgeeks

unread,
Oct 9, 2012, 11:55:39 PM10/9/12
to phon...@googlegroups.com
git is probably not installed (Xcode command line tools?) or it's buried inside the Xcode.app :/

Something like    /Applications/Xcode.app/Contents/Developer/usr/bin/git

:\

WebSteve

unread,
Oct 10, 2012, 2:35:48 PM10/10/12
to phon...@googlegroups.com
Here are the actual steps I've taken:
 
1. I downloaded GitHub for Mac from here: http://mac.github.com/.
2. "mac_GitHub for Mac 66.zip" was placed in my Downloads folder. Double-clicking on it unzipped it and produced the app file "GitHub" with a cute icon. I dragged it to my Applications folder.
3. After double-clicking on the icon, I was led through several steps to set up a free account accessible to the public.
4. I received a notice via email that a public SSH key was added to my account.
5. Opening GitHub (not GitHub.com), I went to GitHub > Install Command Line Utility, and it said it was set up at usr/local/github. Not sure where that location is; it's not in Developer/usr/local.
6. I dragged my working directory's folder onto the Terminal app in the dock, making it start at the current working directory.
7. Typed in Terminal:
git init
 
Received response:
command not found
 
I have yet to follow:

Enter git add . to copy your project files into the repository.
Enter git commit -m "Initial commit" to commit all the files.

Am I missing a step or mistepped somewhere?

Kerri Shotts

unread,
Oct 10, 2012, 3:47:36 PM10/10/12
to phon...@googlegroups.com
Make sure git is in your PATH. 


______________________________
Kerri Shotts
photoKandy Studios LLC

📱 Phone: +1 (312) 380-1035
🌐 Web: http://photokandy.com 

Twitter: @photokandy

--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
 
 

WebSteve

unread,
Oct 10, 2012, 5:17:41 PM10/10/12
to phon...@googlegroups.com
Here's my adventure in a nutshel (NOT): 

Set up GitHub Locally

1. I downloaded GitHub for Mac from here: http://mac.github.com/.
2. "mac_GitHub for Mac 66.zip" was placed in my Downloads folder. Double-clicking on it unzipped it and produced the app file "GitHub" with a cute icon. I dragged it to my Applications folder. 
3. After double-clicking on the icon, I was led through several steps to set up a free account accessible to the public (private accounts are monthly paid accounts). 
4. I received a notice via email that a public SSH key was added to my account, which key was full of paired letters and digits separated by colons. I copied it to a safe place on a folder that is backed up regularly. 
5. Opening GitHub (not GitHub.com), I went to GitHub > Install Command Line Utility, and it said it was set up at usr/local/github. Not sure where that location is; it's not in Developer/usr/local. 

Set up GitHub.com

1. Sign up at GitHub.com.
2. Click on New Repository.
3. Give the repo a Name ("Font-Change-and-Bookmarks").
4. Give a substantial Description. This will become your README! Put in everything you want the people to know about how to implement your files. ("Creates buttons to add page bookmarks and font-size changes buttons coded in Javascript in a row at the top of the page in an HTML file. Go to http://iphonedevlog.wordpress.com/ for full instructions.").
5. Select the checkbox for "Initialize this repository with a README."
6. Click on the drop-down for Add .gitignore and choose "Objective-C."
7. Click on Create repository.
8. The next page will show you the public face of your git repo with the Code tab showing. Clicking on the Admin tab, you'll see where you can change the repo name, and unselect Wikis and Issues checkboxes if you don't think you'll need or use them. Scroll down and you'll see a Delete this repository button.

Create an Empty Repository Locally

1. In Xcode, I installed the command line tools by going to Xcode > Preferences > Components tab, and selecing Command Line Tools (115.6 MB), then Install. Where was it installed? Click on Xcode > Preferences... then on Locations, Locations. You'll find it installed in /Applications/Xcode.app. (That tab will also inform you where your Snapshots and Archives are stored.) 
2. In Xcode, Help > Search > Repo brings up Setting up a Git Repository. The next four steps are given, which I followed:
a. Drag your working directory's folder onto the Terminal app in the dock, making it start at the current working directory.
b. Again drag the folder to Terminal and enter the following to create an empty repository.
git init
Terminal's response: is a directory
c. Again drag the folder to Terminal and enter the following to copy your project files into the repository.
git add .
Terminal's response: is a directory
d. Again drag the folder to Terminal and enter the following to commit all the files.
git commit -m "Initial commit"
Terminal's response: is a directory

3. Open GitHub. At top is a breadcrumb navigation; click on Repositories, then click on your GitHub sign-in name (not project name) that the repos fall under. You should see your recent repo listed. Or click on the refresh button below to show it. 
4. The top right showed a green symbol. Clicking on it showed a notification that an upgrade was available. That icon goes away when you relaunch with the upgrade. 
5. Click on clone to Computer, and choose a location for the repo locally. I put mine in Documents/GitRepo
6. Click on My Repositories under Your Computer and your repo should show up. Click on the right arrow. 
7. Click on Changes and fill in the summary and description fields, then hit Commit & Sync. If you have not made any changes to the project folders, nothing will happen. 

SO FAR, I have not been able to actually commit all my project files online -- only uploads changed files since downloading the git. 

Steve Sobol

unread,
Oct 10, 2012, 5:51:50 PM10/10/12
to phon...@googlegroups.com

----- "WebSteve" <shus...@aeteam.net> wrote:

> 5. Opening GitHub (not GitHub.com), I went to GitHub > Install Command
> Line Utility, and it said it was set up at usr/local/github. Not sure
> where that location is; it's not in Developer/usr/local.


...off the root directory maybe? like /usr/local/github?


--
Lobos Studios - Website Design, Programming, IT Support
Phone: 877.919.4WEB (Toll-free) or 760.684.8859 (Victor Valley)
www.LobosStudios.com * www.facebook.com/LobosStudios * @LobosStudios

Fred Stluka

unread,
Oct 10, 2012, 6:09:03 PM10/10/12
to phon...@googlegroups.com
Steve,

If you haven't used a distributed VCS like Git before, you may
be missing one key concept:

There are multiple Git repos, one local and one at GitHub.  Each
is a complete copy of the entire repo, including all old versions
of all files.  Neither is just the latest version of each file.

The typical sequence of operations, using the Git verbs:  clone,
add, commit, push, pull,
etc, is:

- Create a repo at GitHub
- Clone the repo locally
- Now you have 2 empty repos, one local, one remote
- Add the files you want to manage to the local git repo
- Commit, which causes all added files to be added to
   the local repo (or updated, if they had been previously
   added and committed)
- Push, which synchronizes the local repo with the remote
   repo, pushing all of the files to GitHub

Then, someone else on your team may do:
- Clone the repo locally to his machine, so he now has a 3rd
   repo, just like the other 2, with all versions of all files
- Create/edit/delete some files
- Add the files he created/edited/deleted
- Commit, which causes all of his creations/edits/deletions
   to be applied to his local repo
- Push, which synchronizes his local repo with the remote
   repo, pushing all of the creations/edits/deletions to GitHub

Then, you may do:
- Pull, which synchronizes your local repo with the remote
   repo, pulling all of the creations/edits/deletions to GitHub

After that, you can each do any of the following, as many times
as you like independent of each other:
- Create/edit/delete files
- Add the files
- Commit
- Pull, to merge the other person's latest changes into with
   your local updates
- Push, to push the merged changes back to GitHub

If you both edit the same file, and both add, commit, pull and
push, Git will merge both sets of changes into the file, so
nothing gets lost.  If you both edited the same line in the same
file, Git will report a "merge conflict", and you'll have to manually
edit the file to properly apply both changes to that line.  Your
starting point for that edit will be the file that Git creates
containing both versions of the line with special "<<<" and ">>>"
types of flag lines to show the 2 alternatives.

Does this make more sense now?

I suspect you've been doing commits to your local repo, but
never pushing the commits to GitHub.

BTW, the commands you are looking for are probably in
/usr/local, not in /Developer/usr/local.

--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

WebSteve

unread,
Oct 10, 2012, 6:53:34 PM10/10/12
to phon...@googlegroups.com
Kerri, that missing step got me further along! Thanks! Now I have:

Create an Empty Repository Locally

1. In Xcode, Help > Search > Repo results in "Setting up a Git Repository." The next four steps were given: 
a. Drag your project's folder to the Terminal icon to set the starting directory.
b. Enter the following to create an empty repository: 
git init
Terminal result: Reinitialized existing Git repository in /Users/Steve/Documents/BookmarksFontChange/.git/
c. Enter the following to copy your project files into the repository: 
git add .
Terminal result: cursor
d. Enter the following to commit all the files: 
git commit -m "Initial commit"
Terminal result: [master ff4366e] Initial commit 2 files changed, 0 insertions(+), 0 deletions(-) 

I'm not sure exactly what I created, to be honest. I went into Xcode for the above project and looked into Organizer. It did not see any extra repository. I expected a local repository to have been created. I opened GitHub on my machine and it did not see any repositories either. 

Yes, I've read and reread the docs over and over about how "easy" it is to do from the command line. But the steps before doing all that are not clear, nor after. It's not easy until it's all set up. 

WebSteve

unread,
Oct 10, 2012, 6:57:30 PM10/10/12
to phon...@googlegroups.com
- Create a repo at GitHub
Clone the repo locally
- Now you have 2 empty repos, one local, one remote
Add the files you want to manage to the local git repo
Commit, which causes all added files to be added to
   the local repo (or updated, if they had been previously
   added and committed)
Push, which synchronizes the local repo with the remote
   repo, pushing all of the files to GitHub

Now that I have the command line working, I'll work on the above sequence. That is the correct order, right? Or did I need to even bother with the command-line stuff and I just needed to do the above steps only? That's what's not clear. 

How the command-line relates to the GitHub.com relates to the Mac GitHub app relates to the Xcode repository management. These are the connections I am trying to work out. 

WebSteve

unread,
Oct 10, 2012, 7:04:44 PM10/10/12
to phon...@googlegroups.com
- Create a repo at GitHub
Clone the repo locally
- Now you have 2 empty repos, one local, one remote

I did the above steps. 

Add the files you want to manage to the local git repo

How do you do this? I assume you are talking about GitHub which I downloaded for the Mac. I don't see an Add. It goes from clone to commit. 

Fred Stluka

unread,
Oct 10, 2012, 7:44:49 PM10/10/12
to phon...@googlegroups.com
Now that I have the command line working, I'll work on the above sequence. That is the correct order, right? Or did I need to even bother with the command-line stuff and I just needed to do the above steps only? That's what's not clear.

Yes, you can do it all from the command line, via the "git"
command:

git add
git push
git clone

etc.

I'm using a Mac, and git, and GitHub.com, but haven't yet
tried the Mac GitHub app you mentioned, so I don't know
details of it.  (Wherever I said "GitHub", I meant GitHub.com.)
There should be an "add" somewhere in the UI though, I'd
think.  Or maybe you just drag/drop files to add them.


How the command-line relates to the GitHub.com relates to the Mac GitHub app relates to the Xcode repository management. These are the connections I am trying to work out. 
The basic software is "git".  It includes command line commands
to create and manipulate repos and files.  There are also various
GUI tools you can get to do the same commands for you, operating
on the same repo.  For example:  gitx, gitk, gitgui.

GitHub.com is a Web site where they will store git repos for you,
and you can use their Web UI to create and manipulate repos and
files, as well as get lots of reports, notifications, etc.  GitHub.com
runs the same git software that you can use on your local
computer from the command line, or via a local GUI.  However,
it operates on your git repos stored at that site, not on the git
repos stored on your local computer.  Except of course for the
push, pull and clone operations which synchronize your local
and remote repos.

You can use git with out GitHub.com, keeping your remote git
repo on any server you have access to, or even having only local
repos on your local computer.  However, the Web UI at
GitHub.com adds a lot of additional features, so it is very popular.

The GitHub app for Mac is probably another GUI tool that operates
on your local git repo, but likely also has special hooks that are
useful if your remote repo is at GitHub.com.  It almost certainly
uses the standard git software, and is just a UI wrapped around it.



--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

Fred Stluka

unread,
Oct 10, 2012, 7:51:02 PM10/10/12
to phon...@googlegroups.com
How do you do this? I assume you are talking about GitHub which I downloaded for the Mac. I don't see an Add. It goes from clone to commit.

The Mac GitHub tool must have a way to add files to a git repo.
If there's no menu item called "Add", maybe it's done via
drag/drop or something.  Also, add requires one or more files
and/or directories as a parameter, so it might not be in the
main menu.  Perhaps you have to select the files and then
right-click to pop up a context menu?


--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

WebSteve

unread,
Oct 11, 2012, 12:10:46 PM10/11/12
to phon...@googlegroups.com
Regarding adding files:
I had earlier followed these steps:

a. Drag your project's folder to the Terminal icon to set the starting directory.
b. Enter the following to create an empty repository: 
git init
Terminal result: Reinitialized existing Git repository in /Users/Steve/Documents/BookmarksFontChange/.git/
c. Enter the following to copy your project files into the repository: 
git add .
Terminal result: cursor
d. Enter the following to commit all the files: 
git commit -m "Initial commit"
Terminal result: [master ff4366e] Initial commit 2 files changed, 0 insertions(+), 0 deletions(-) 

I noticed that I used the "git add ." command. Presumably this added all my project files into a local repo. I"m not sure what I did, but at last Xcode recognizes a repo associated with my project in Organizer. However, it doesn't show the files in my www folder. 

Fred Stluka

unread,
Oct 11, 2012, 6:34:42 PM10/11/12
to phon...@googlegroups.com
Steve,

Yes, with the command:
     git add .
you told Git to add all files in the current directory tree to the
list of staged files that would be operated on by the next commit.

Then, with the command:
    git commit
you told Git to commit all staged files to the local Git repo

If you then want to push all of the recently committed files from
your local Git repo to a remote repo at GitHub.com or elsewhere
that your local repo was associated with previously via a git clone
command, you would use the command:
    git push


--Fred
Fred Stluka -- mailto:fr...@bristle.com -- http://bristle.com/~fred/
Bristle Software, Inc -- http://bristle.com -- Glad to be of service!
Open Source: Without walls and fences, we need no Windows or Gates.

Message has been deleted

WebSteve

unread,
Oct 12, 2012, 2:30:34 PM10/12/12
to phon...@googlegroups.com
I am much further along, having gotten the files up to GitHub. However, If I do a git rm to get rid of a file locally, then git commit, the terminal wants me to enter the commit message. Once I enter some text, however, I don't know how to execute it. Hitting the Return button merely enters a new line in the terminal. 

Thanks for all your help!
Steve 

Icekream

unread,
Sep 18, 2013, 8:07:20 PM9/18/13
to phon...@googlegroups.com
Just a question here

If I create a .git in the same folder as the .xproject file doe the git get added to the compile process when building the app?

Steve Sobol

unread,
Sep 18, 2013, 8:10:37 PM9/18/13
to phon...@googlegroups.com
You know, I have a Git question too.

I have a cross-platform app I'm working on that I'm pushing to a Git repository. I work on the iOS side on my Mac Mini, and on the Android side on Eclipse under Windows 8.

Is it necessary for me to commit the entire Cordova project, including the entire Xcode project and the entire Eclipse project (which is what I'm doing now)? Can anyone think of any technical issues with me just committing the top-level www/ directory?

Wednesday, September 18, 2013 17:07
Just a question here

If I create a .git in the same folder as the .xproject file doe the git get added to the compile process when building the app?

On Friday, October 12, 2012 2:30:34 PM UTC-4, WebSteve wrote:
--
-- You received this message because you are subscribed to the Google
Groups "phonegap" group.
To post to this group, send email to phon...@googlegroups.com
To unsubscribe from this group, send email to
phonegap+u...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/phonegap?hl=en?hl=en
 
For more info on PhoneGap or to download the code go to www.phonegap.com
 
To compile in the cloud, check out build.phonegap.com
---
You received this message because you are subscribed to the Google Groups "phonegap" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phonegap+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Lobos Studios - Website Design, Mobile App Development, IT Support
Toll Free Phone/FAX: 877.919.4WEB
Victor Valley Phone/FAX: 760.684.8859
Los Angeles Phone/FAX: 310.945.2410
Business Cell: 310.487.2362

Icekream

unread,
Sep 18, 2013, 8:36:04 PM9/18/13
to phon...@googlegroups.com
@SteveSobol

I'm attempting the exact same thing I have setup my www files in eclipse( on windows 7) as my main editor and pushed it to bitbucket. Now I am attempting to fetch the repo into an xcode project( virtualbox OS X ). At first i tried to add the repository via the organizer but ran in to some trouble so I had to setup the git via terminal....I set it up in the project folder( which I think maybe wrong. Some one correct me on this). From there I tried to add a remote via xCode but was getting a failed authentication when trying to connect to the server. So I'm now trying to do this the terminal way. Will let you know how it turns out
Reply all
Reply to author
Forward
0 new messages