Submit Your Project to Github

Your project could be a web site, an android app or an iOS app etc so let’s take an iOS app example using Xcode on Mac OS X Yosemite.

  1. Create a Git repository on your local computer via:
    1. Xcode
      Create a new project with a local Git repository option checked from New Project Template.
    2. Terminal
      Jump inside your project folder
      $ cd path_to_your_project_folder
      $ git init
      $ git add .
      Make sure to set user.name and user.email as it will appear in GitHub for initial commit. How? It is discussed down in this post.
      $ git commit -m “Initial commit”
  2. Create your GitHub remote repository on GitHub with either same name as your local repository or anything else but skip the initialization and adding readme.md file options. When you’re done, write down the SSH url of the GitHub repository that you’ve just created.
  3. Now you would add the SSH url to git so that it can know where to submit the local project. Here you have two options:
    1. From Xcode
      This option used to be there in Xcode’s Organizer under your repository as “Add Remote” button but now it seemed missing and might be somewhere else so I would prefer the Terminal option instead as discussed next.
    2. From Terminal
      Jump into your project folder on terminal
      $ cd path_to_your_project_folderHere you can check the status of remote info for your repository
      $ git remote show origin
      $ git remote -v

      You would add your GitHub repository’s SSH url as follows:
      $ git remote add origin paste_your_github_repo_ssh_url

      Before submittingmake sure to either set your email (GitHub prefers yourusername@users.noreply.github.com) in your git on your computer
      either for every repository
      $ git config –global user.email “your_email@example.com”
      or for a single repository
      $ git config user.email “your_email@example.com”

      and confirm that you’ve set the email correct either for global or current repo
      $ git config –global user.email
      $ git config user.email
      or read the config file
      $ vi .git/config
      and similarly set and confirm user.name

      Now time to submit/push your project
      $ git push -u origin master

      And you’ll be prompted for yourGgitHub username and password like here
      Username for ‘https://github.com’: xxxxxx
      Password for ‘https://xxxxxx@github.com’:xxxxxx

      You’re done everything right. If you decide to create a new account on GitHub and try to push to your new account then you may get the following error:

      remote: Permission to NEWUSER/NEWREPO.git denied to OLDUSER. fatal: unable to access ‘https://github.com/NEWUSER/NEWREPO.git/’: The requested URL returned error: 403

      It should fix by setting the user.name either for global or current repo
      $ git config –global user.name NEWUSER
      $ git config user.name NEWUSER

      But it doesn’t, at least it didn’t for me. I know one solution on Mac OS X that is to delete the OLDUSER associated with GitHub from Keychain Access app under Passwords section. Now push would go successful.
      $ git push -u origin master

  4. Now you can add readme file from your GitHub account for your submitted repository.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s