Git learning note

Finally I am released from a long-term report mission so …

Why learning Git, AGAIN!?

While waiting my application for RC start being reviewed, I am also considering myself how I can improve my programming skills by myself. Git is one of those things that I think I should be better at, because version control is essential no matter I am programming scientific compuation program or commercial software. There is a perfect git tutorial from a resident of Recurse center. But I think I’d better do some warming up exercises before diving into that, so here we go.

Before using

We need to do some house-keeping work to make sure everything is set properly.

  • to tell git our name and email address.
git config --global "Firstname Lastname"
git config --global user.emal ""

Note that all these information will be saved to a local file .gitconfig in home directory (linux). And it’s legal to manually change the file directly.

  • Concept of Github and preparation of SSH key for Github.

Github works as a remote repository that can hold your project and be accessed from anywhere with available internet connection. In order to connect to Github repository, you need SSH key besides account name and password for security reason. To generate your SSH key on local working machine:

ssh-keygen -t rsa -C ""

Then you should find two new files generated, one called “id_rsa” is your secret key, and “” is public. They are paired to each other.

Then log into your Github account on webpage, choose [Add SSH key] to upload your public key to Github and you should be OK to go.

Most basic operations

Suppose you have created a repository called “Hello-world” on Github.

In order to “clone” the repository from Github:

git clone

will copy all the files in that repository to your local directory.

Note the “git clone” command is not only for copying from Github, but is also valid to do a local clone.

git clone old-project ../new-project

will create a copy of current directory to a folder called new-project.

Then you make some changes to file, before you commit the changes, you need to add this file to make it ready for commit ( or in the Github terminology: to STAGE it ).

git add example.txt

Finally you commit this change and add your comment by:

git commit -m "Your comment here."
git push

Always check the status of current directory by:

git status
git log

And that’s all the basic of basic, of git and Github.

Written on March 5, 2016