GitHub Commands

December 1, 2015


It has been a long time since I made the last update to this blog. I have been busy with a project where we use GitHub to synchronize our source codes. This is a very useful website to provide users the access to source codes, examples, wiki, and documentations. There are thousands of tutorials online for GitHub, but in my case, I think the following commands are the most useful ones:

  • git clone https://github.com/[repository location]: Download a project on GitHub to your local directory.

  • git add [file name]: Add a new file in your local directory.

  • git rm [file name]: Remove a file in your local directory.

  • git commit (-m [message]): Commit the changes you made in the local directory (with optional message).

  • git push (origin master): Upload your local directory to the remote repository (with optional branch information).

There are also other commands like checking out different versions, stash commits, etc. However, I have been using the above 5 commands most frequently. People can also add the following files:

  • .gitattributes: users can make specific changes to the committed files, so they are automatically modified when being uploaded.

  • .gitignore: users can ignore specific files in the local directory when uploading. This can be used to ignore the target files.

In principle, the commits will be recorded by GitHub to show the contributors. There are so many interesting features on GitHub to be explored.