Thursday, June 16, 2016

Version control: Backing up your data

In my first job as an engineer, we already practiced data backup. The main goal obviously to keep a copy of your dearest work so that you can get it back following an unfortunate circumstance. We used a simple USB stick or portable harddisk. When I worked in the company just before starting my PhD, we used an online repository with version control. All these were done in Windows machines. Now, version control is particularly important when you work in a team with a certain tight schedule to achieve. With version control, multiple users or programmers can work on their piece at the same time and commit ("apply changes") the updates accordingly.

About four years later, I'm doing the same thing. There are many things we need to backup. A large part of my graduate work involves coding: Matlab script, bash script for neuroimaging analysis, and InMotion robot script in Tcl/Tk. A set of codes we are working on is called a working copy. Currently, I'm backing up my so-called working copy from a Linux computer using a Subversion or SVN, a type of version control platform. Another platform called Git has a similar purpose but different set of commands. For example: git clone is similar to svn checkout;  git pull is similar to svn update;  git commit -a .... then git push (push to a server) are the same as svn commit. In git, one has to ensure that a new file/change is added before doing any commit. A "commit" represents a collection of changes that we are ready to apply to the repository.

This website is kinda helpful for beginners;  http://www.tutorialspoint.com/svn/

I found the following schematics from this website very useful, I'm a visual person maybe.
I'm also introduced to three different online repositories: Assembla (for SVN), GitHub, and BitBucket. These three are free for personal use. I put my important items such as research notebook, lecture notes, forms, scientific papers in Dropbox (with 7 GB size). This online space doesn't require any version control. It's quite sad to see Copy closing down, it has a bigger drive space for my data.

How does git work? What is a git branching and merging? The following website sums up everything: https://git-scm.com/book/en/v1/Git-Branching-What-a-Branch-Is
If one is working in a team, he/she has to work on one particular function while others on their functions too. How do they code in parallel? They have branches that are derived from a Master copy. Once they are confident the code works, they usually run a test suite on their code first before merging back into the Master copy.

Another useful info is the cheat-sheet here.

No comments: