Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Add Xcode project to github repo?

I have JUST created a new github repo on the website. Keep in mind that I am a noob but can do basic things in terminal. Anyway, so I just created the repo on my account on github.com and didn't do a single thing to it yet.

So all I want to do is take my Xcode project folder and upload it to my new github repo. How do I do this via terminal?

like image 702
SimplyKiwi Avatar asked Oct 02 '12 21:10

SimplyKiwi


People also ask

How do I open an Xcode project in GitHub?

Open your XCode application. Go to the Source Control Tab of XCode and go to Clone. Enter the repository URL you copied in the above step in the search bar at the top of the dialog and hit the Clone button. It will now ask you to sign in to your github account where the given repository is made.


2 Answers

The best way really is to follow the instructions GitHub gives you:

First, go the correct directory

cd <directory of your Xcode project> 

It sound like you've already got a local Git project from Xcode. If that's true, skip this code block.

git init . git add . git commit -s <type in a commit message> 

Last, push into your repository. The following is copied directly from my own github account, after I created a new "test" repo. Change the "dhalperi/test" part.

Push an existing repository from the command line

git remote add origin [email protected]:dhalperi/test.git git push -u origin master 
like image 125
Dan Halperin Avatar answered Oct 23 '22 18:10

Dan Halperin


I was just going to leave a comment above but I will also add a summarized answer. My full answer is here.

This isn't via terminal as the question requests, but you can consider this an alternate method. It is well integrated with Xcode now, though, and not difficult to do.

Create Git repository when making a new project

enter image description here

See the answer I linked to above if you already have a project without a Git repository.

Make a Commit

enter image description here

After making a change in your project, select Commit... from the Source Control menu. You will add a short commit message.

Create a new GitHub repository

enter image description here

On the GitHub website make a new repository. Call it whatever you want, but don't add a README or .gitignore or license yet. After creating the new repository copy the link to it.

Add a Remote in Xcode

in Xcode go to Source Control > your branch name > Configure. Then click the Remote tab > "+" button > Add remote. Fill in your repository name and address.

enter image description here

Push your project to GitHub

Go to Source Control > Push. You will have to enter your GitHub user name and password the first time.

That's it. Now any time you make changes in Xcode, all you have to do is Commit and Push.

If you didn't follow this explanation, please read this and this for more detail.

Further Study

This is an excellent video that I recently watched that helped me understand Git and its integration with GitHub much better.

  • The Basics of Git and GitHub
like image 23
Suragch Avatar answered Oct 23 '22 19:10

Suragch