We intend to implement the consequent utilisation of version control tools such as git or subversion. These little pieces of software keep a register of the files you are working on and track all changes. At the cost of very little extra effort in your everyday workflow, this brings the following benefits:
simulation.cpp
simulation_v0.1.cpp
simulation_v0.2.cpp
simulation_v0.2.1.cpp
simulation_in_review.cpp
simulation_messed_up.cpp
You also might have several copies of the code file in differently named directories. You might have made some little changes to the file in each of them. This clutters your project's working directory. Version control makes this redundand since the software keeps track of your work now. It allows you to make changes to your main code file and return to a previous version anytime you want. You even can keep several branches of that single code file. Still, there is only one file found in your working directory called simulation.cpp
.First a few words in general about what git actually is and what it can do. I see two main purposes of it:
The very first purpose is version control of a project. This can be a piece of software or a written document, for example. As a developer or author you might want to keep track of your progress. Maybe you want to go back to earlier versions, because you somehow messed it up, or just because you liked it better. This ensures a continuous improvement of your project.
The second purpose is collaboration. Git allows you to share the whole project with others. It does track, who was doing changes on the project's files and is able to merge things together if the collaborators were working on different parts of the projects.
If you think about it, this is also exactly the thing you need if you are working from different computers, e.g. from work and from home. So we can add synchronisation to that list.
git also helps with building up an organisational structure for complex software development. It is easy to work on different parts of the project at the same time and merge those so-called branches together afterwards.
If you have a GitHub account, GitHub for Windows or GitHub for Mac are clean and convenient tools to use. It installs a command line shell that includes all the utility that is required for git and the connectivity to GitHub. However, the actual GUI is not very flexible and uses a completely different vocabulary (syncing, updating) than the actual git. Alternatives are git for windows. Many IDEs for code development come with a convenient git interface (e.g. RStudio, Eclipse).
In Ubuntu, git can be installed via
apt-get update
apt-get install git
Then you should set your user properties.
git config --global user.name "Your name"
git config --global user.email your@email.com
git config --global core.editor gedit
This just tells git under which name commits should be performed and which texteditor to use for requiring messages.
The principles of git are explained on the internet at length and short, and it is worth looking into it, even if some clients make it a point-and-click adventure.
I only want to point out that git can be used on your local computer in any directory you like to put under version control. If no collaboration or syncing is necessary the commands git add
and git commit
are all you need. Maybe you will want to set a .gitignore
file that excludes some directories or files from being tracked.
If you want to sync your versions to a remote server (e.g. to GitHub) for personal back-ups or to share it with others, you will need git pull
and git push
.
If a linear workflow is not sufficient and you want to apply more elaborate procedures such as branching and you will need to understand git branch
, git remote
, git merge
, and more.
Useful are tags that can be set at any point in the project development that seems noteworthy (for instance the start of a simulation, sending the code to a collaborator, the submission of a manuscript) using git tag
.