Git: Setting Up Git on GitHub

By Xah Lee. Date: . Last updated: .

Here's minimum steps to setup git using GitHub.

[see Github Mascot: Octocat in Many Guises]

First, install git on your machine.

which git → check if git is installed and path setup correctly. If so, you'll see a path. Else, nothing.

sudo apt-get install git → install git (Ubuntu Linux).

For git command line basics, see Git Tutorial: Practical Git in 1 Hour.

How to get code from github?

Go to a github site, you'll see “clone url”, copy the URL. Then, do this:

# clone a repository
git clone

This will create a dir of the project name in your current dir.

How to put your git repository on github?

① go to to create a account.

② create a new project. On github site, click the “Create a New Repo” button, then fill out the form. You have to do this on github website.

③ on your machine, create your git repo if it doesn't exist.

# init git in my-project
cd my-project
git init
git add .
git commit . -m"initial commit"

④ On your machine, cd to your project dir, then create a association of a name and a remote repository URL. Like this:

git remote add name url → Associate the name name with the URL url of remote repository.

# associate a name to remote repo
cd my-project
git remote add github

This will associate the name “github” with that URL. So later on, you don't have to type the full URL when you want to push code to github.

That's it. You are done.

git push github master → push the “master” branch to the remote server. You can add a -u (or --set-upstream) option. The -u option will save you from typing a remote server name when you do git pull.

git pull github master → pull from github. This will update your local repository from github.

How to get your github id?

go to a url of this form:

replace your user name there.

If you have a question, put $5 at patreon and message me.


  1. Install git
  2. Git Basics
  3. Git Ignore File
  4. Commit Files
  5. Push to Server
  6. Pull from Server
  7. Find Difference
  8. View Log
  9. Revert Change
  10. Branching
  11. Temp Save: git stash
  12. What's HEAD
  13. FAQ