Simple GitHub Tutorial

I have posted a tutorial of Git (See Simple Git Tutorial). But it mixed up using Git and using GitHub together. I post this new tutorial to draw a line and make things clear.

Notice: If you run into any problems, it's highly recommended that you check out Github Docs, or Google it. If you still can't solve it, you can comment below this post.

Creating a Github Account


Checking your Local Git Config

Make sure that you have told Git your name and email. That is say, you should have run:

git config --global "<your_name>"
git config --global "<>"

Also see:

Connecting to GitHub with SSH

You are recommended to connecting to GitHub with SSH (instead of HTTP/HTTPS).

First, generate a new SSH key using new ED25519 algorithm:

ssh-keygen -t ed25519 -C "<>"

Then, Keep on repeating pressing Enter until your prompt appear again.

Finally, add your public key to GitHub:

  1. Go to SSH and GPG keys - GitHub.
  2. Click the green New SSH key button at the top right of the page.
  3. Fill out the form, where key is the content of ~/.ssh/ (This file is generated by the ssh-keygen command above. You may run cat ~/.ssh/ on Linux or Mac or run notepad ~/.ssh/ on Windows to check its content).
  4. Submit the form by clicking the green Add SSH key button.

The postfix .pub indicates that the file is a public key. The ssh-keygen command above also generates a private key file id_ed25519 (without the .pub postfix).

Also see:

Due to the special network environment in China, you may often need to use proxy service to get a better browsing experience. Generally, when you enable the System Proxy option, only the traffic on port 80/443 (corresponding to HTTP/HTTPS) will go through the proxy server, while the traffic on SSH's default port 22 will not. With the following settings, you can force SSH traffic to go to port 443.

To test if SSH over the HTTPS port is possible, run:

ssh -T -p 443

Type yes if you see some info like:

Are you sure you want to continue connecting (yes/no/[fingerprint])?

If you receive response like below, it means it's OK:

Hi USERNAME! You've successfully authenticated, but GitHub does not
provide shell access.

You can now override your SSH settings to force any connection to to run through that server and port. Edit ~/.ssh/config and add this section:

Port 443
User git

Now your usual command like:

git clone

is equivalent to:

git clone ssh://

Also see:

GitHub Cli


Basic Usages


You can use git clone to clone an existing repo from GitHub. The simplest form looks like:

git clone <url> [<local_directory_name>]

where center brackets mean that <local_directory_name> is optional.

It's no longer recommended to use http/https url to clone. Using url like!

If you want to specify a branch when cloning, you can use -b option:

git clone -b <branch> <url>

If you don't want to include all commits, you can use the --depth option. This is helpful when cloning a large repo (you don't need so many commits before actually).

git clone <url> --depth=1

Next Steps