Photo by Paul Hanaoka on Unsplash

What is Github?

Jeffrey Ng
3 min readNov 18, 2020

--

Github is a version control system (VCS) that organizes and manages open source projects. It starts with a repository with the main project in it. Users can then maintain their own copies with a “forked” repo or on their “branch” of this repository (repo) and work on them independently. These saved work copies can then be added, committed and then pushed to the main repository. This is the main gist of the workings of Github. It is in no way a complete guide to Git, however. For the best resource on using Github technology please refer to https://guides.github.com/

Github has many commands to help us stay organized and monitor our work in progress. Because it’s a VCS, it provides different versions of the projects. As mentioned before, repos that are public can be forked to a local directory and cloned via first forking the repo on the page and then performing a git clone ‘URL’ (of forked page) on the OS command prompt.

Let’s go over some frequently used and not so frequently used commands so that we can get up and running with Github.

git init: initializes a blank repo in the current directory from the command prompt

git add + ‘filename’: adds a file to be staged before it gets pushed into a remote repo

git commit -m ‘message’: stages the files to be pushed, and adds a commit message to the end where a description of the nature commit is required

git reset: unstages a file

git push: once the files have been staged, they are ready to be pushed to eth repo

Because Github is a VCS, a user may produce many different copies of a project. Each of these copies can have a sequence of versions. Each of the different copies can be put into different branches (working spaces).

git branch ‘branchname’: creates a branch with the ‘branchname’

git checkout ‘branchname’: allows us to switch to the ‘branchname’

git branch: lists all branches in the repo

With these different branches, one may be able to combine different versions of the work between. We git checkout to the branch we want to merge and use the command git merge ‘branchname’ which merges the current branch with ‘branchname.’ Another useful command is git revert HEAD: which reverts to last committed version. This is called a Rollback. Merges however can cause merge conflicts, when same portions of the project have different versions during merge so computer doesn’t know which version to use. Thus Rollbacks are necessary and merge conflicts can be fixed.

Another useful command is git remote -v which points our work to current repo to push and pull from.

Here are some best practice suggestions:

  1. synchronize your branches before working on your own
  2. git push often and git pull before working
  3. merge frequently between master branch and feature branch
  4. keep stable version of project on master and working version on feature branch

Now lets go git it done!

--

--