GitHub Basics

by Scott, Revised on October 2, 2017 (PerlOpen SourceWeb Development)

A helpful GitHub tutorial: www.atlassian.com/git/tutorials.

Create a repo on Github, then connect your local repo to Github.

Create a directory, cd into it and initialize a repo. A .git directory is created. A .gitignore file can be created as well to prevent tracking of certain files.

git init

Add/develop your project (repeat commands as needed).

git status
git add .
git commit -m 'description'

Connect your local repo to the Github repo.

git remote add origin git@github.com:username/Repo-Name.git

Push/pull as needed.

git push origin master
git pull origin master

Clone a repo.

git clone git@github.com:username/Repo-Name.git

If there are multiple accounts to github on same machine, create separate ssh keys, and create a ssh config file (~.ssh/config). I have found that they both need a different "Host" value then the default of github.com. If one is left as github.com, then that one is used exclusively.

#work account
Host github.work
    HostName github.com
    User git
    IdentityFile ~/.ssh/github.work

#my account
Host github.mine
    HostName github.com
    User git
    IdentityFile ~/.ssh/github.mine

And use:

git remote add origin git@github.mine:username/Repo-Name.git

Tags: PerlOpen SourceWeb Development