June 10, 2018

Simplified git workflow


After one year of git usage I want to give a short feedback about do's and don't in using a version control system. At first let es describe some antipattern which is not useful in reality. First, the usage of branches and second to add single files to a repository. Now let us describe, what a ideal use case in git is. Only one branch is created, the master branch and in this branch certain subfolders are used. They can be called like a project together with a date, for example a subfolder is called “2018-feb-02-behaviortree”. In this subfolder all the sourcecode files are stored. If the programmer want's to create a git snapshot he is not deciding which files are important and which not, but he adds all files to the git repository:
git add --all && git commit -m "comment"
That means, the usage of git is very similar to a normal working directory, except that every hour a git snapshot is created which is comparable to a zip-file. Somebody may argue that git-branches are an important feature and it is not a good idea to commit everything on master. Really? Wikipedia for example uses no branches, and the version control system works great. Branches become only interested if the same repository is duplicated. For example, if an external user is making a copy of the working directory and modifies it. Than the branch is equal to a asynchronous copy. But in normal life, the sourcecode is not separated into branches but into subfolders. That means, if somebody want's to try out some modifications, he is not creating a branch but a subfolder. And he commits the subfolder with all the files into the git repository. That means, he can see both folders at the same time:
1. “2018-feb-02-behaviortree”
2. “2018-feb-05-behaviortreetemp”
The advantage is, that even people who are not familiar with git are able to understand the directory structure. Because there is only one version, the trunk snapshot from the master-branch and in this version different subfolders are stored.