Adding a new repo to github – quick steps

Quick notes on adding an existing project to github

Check you’ve got public key auth set up properly on github:

ssh -T git@github.com
# Attempts to ssh to github

You may see this warning:

# The authenticity of host ‘github.com (207.97.227.239)’ can’t be established.
# RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
# Are you sure you want to continue connecting (yes/no)?
Don’t worry, this is supposed to happen. Verify that the fingerprint matches the one here and type “yes”.

# Hi username! You’ve successfully authenticated, but GitHub does not
# provide shell access.
If that username is correct, you’ve successfully set up your SSH key. Don’t worry about the shell access thing, you don’t want that anyway.

In the local project, assuming it’s not under any VCS at the moment:

git init
git add .
git commit -m "initial commit"

Create a new repository on the command line

On github, create a new empty repo

Note the lines it tells you under “Push an existing repository from the command line” – or edit these ones:

git remote add origin git@github.com:Polsonby/test.git
git push -u origin master

Do those in the new working directory, which will add the github repo as an upstream origin repository for your local one, then push the entire history up to the master branch on there, synchronising them.

Then do

git pull
or
git push

as needed to sync between local and remote.

Advertisements