July 20, 2016

Git & Github

Intro

Git is the name of this software.

Github is the 'hosted' version of this software - stored in a remote server.

Git stores the project's codes and files.

Git helps programmers in Versioning the codes - each changes they make to the codes will be tagged to a running number, normally with a comment what changes has been done.

Git helps several programmers to collaborate - work together in a single project by making sure everyone can have the latest updated codes at any time and everyone is aware what changes are done to the codes - by reading their comments.



Some terms


Repository : The storage for the codes.

Trunk : Main version of the codes stored in the repository.

Branch : Codes which are derived from trunk (main version). Normally, a programmer will have their own personal branch to work on instead of working directly on trunk - this is to preserve the trunk. So, this could be the first thing they do - branched from trunk. Branched is done on the remote repository - so, basically we creates a copy of the trunk at the remote repository.

Checkout or Clone : Download the current version of the codes from the remote repository to our pc and saved them locally as "local repository". This is usually done the first time we get the codes - checkout from our personal branch.

Origin or Master : The location where codes are checked out from.

Fetch : Get the latest version of codes from remote repository but not merging to the current codes in local repository yet.

Pull : Fetch and Merge at the same time.

Commit : Save the latest changes we did on the local repository to a version. Typically done with a comment what changes have been done.

Add : Add new file for the next commit (see below)

Push : Upload current codes (which has last commit) of local repository to the remote repository, typically to the remote branch.

Merge : "Compare" and "Combine" two versions of  codes. Normally, once all changes are completed on one branch, the branch will be merged to trunk. This will typically happened at the end stage of development.

Conflicts : The differences between two versions of  codes. Occurs when one tries to merge two versions of codes together (i.e. trunk vs branch) that have some differences. Conflicts need to be "resolved"



Typical Workflow

At remote repository, branch from trunk. We get the most updated version.

Checkout the branch to a local repository at our pc.

Make some changes on the codes.

Commit with a message - versioning will be done automatically.

Make more changes on the codes.

Commit with another message - new version created.

Some more changes and commit cycles.

Work are done.

Push the branch in our local repository to the branch in remote repository.

Try to merge the remote branch to the trunk.
   
Conflicts with occurs at this point since we are updating the trunk with our changes. Resolve them.
   
Once merged to trunk, trunk will have our latest codes.
   
Another programmer will try to merge his branch to the trunk.
   
If any conflicts occurs, he need to resolve them first. Typically, if two programmers don't work at the same issues, there will be not much conflicts or conflicts can be easily resolved.



To start, install Tortoisegit below and start checking out from any Github repos :
https://tortoisegit.org/about/screenshots/#Explorer_integration