Skip to content

Commit fc24318

Browse files
authored
Docs/git workflows (#268)
1 parent a78ceeb commit fc24318

File tree

1 file changed

+88
-0
lines changed

1 file changed

+88
-0
lines changed

docs/guidelines/git_workflow.rst

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
==========================
2+
Working as a team with Git
3+
==========================
4+
5+
We all have different experiences and habits working on GIT.
6+
Which are very valid and not to be diminished.
7+
When working together as a group, we should strive towards unifying them and have a common agreement on how we work together.
8+
9+
This is the exact purpose of this document - to set a standard on how development should happen using Git.
10+
At least for our workgroup.
11+
12+
The main branch
13+
===========================
14+
15+
Let's start with the basic setup that every repository should have: a protected ``main``/``master`` branch.
16+
Protecting a branch means that at no point is anyone allowed to push to it directly.
17+
Every modification of the code should happen through pull/merge requests (see guidelines below - Merge/pull requests).
18+
19+
When starting work on a new feature, bugfix, documentation improvement or anything else, follow the ...
20+
21+
Git branch naming convention
22+
============================
23+
24+
| As the saying goes:
25+
| *"A large number of branches with seemingly no purpose on a single repository is a strong sign of upcoming chaos."*
26+
| - Timo
27+
28+
Joking aside, branching a repository should happen for a reason.
29+
And the branch should also exist for a reason.
30+
Despite these two statements being seemingly obvious, experience shows that they are often overlooked.
31+
This can then result in a large number of branches that are unmaintained, forgotten and nobody knows why they exist in the first place.
32+
33+
Therefore, we state that there are two distinctive reasons for a branch to exist: it is actively being worked on or contains code that is useful in a certain scenario.
34+
If the scenario becomes irrelevant, so does the code and the branch that hosts it and should therefore be deleted/archived.
35+
36+
In light of this, we set forth the following guideline.
37+
When creating a branch on a repository, have a clear understanding what are you doing it for.
38+
After this, select a prefix from the list below and finally give it a clear name:
39+
40+
- ``feature/`` or ``feat/`` - When creating a new feature or improving the code
41+
- ``bugfix/`` or ``fix/`` - When fixing a known bug.
42+
- ``hotfix/`` - Those little things you spotted that you wanted to fix (typo in the documentation, missing image, wrong comment, delete commented out line, etc.).
43+
- ``doc/`` - When your task is to extend the documentation.
44+
- ``release/`` - Use this for adding changes to the CHANGELOG.md before a new release.
45+
46+
The name should also be rather descriptive but at the same time not too long. Use dashes ``-`` to separate words.
47+
48+
Merge/pull requests
49+
===================
50+
51+
As discussed above, we will add improvements to our code through pull requests.
52+
These allows the author of the code to present their work to others and request their review.
53+
54+
It is very important that the author of the pull request provide sufficient information to the reviewers!
55+
Therefore, each merge request should contain the following elements:
56+
57+
- A brief description what it does and what changes does it introduce
58+
- Instructions how to test the code and the expected results
59+
- Any additional information that will help the reviewer
60+
61+
.. note::
62+
**Commenting-out sections of code**
63+
64+
As a general rule of thumb, if a portion of code is not needed, it should simply not be there.
65+
When developing locally, we often test things by commenting-out sections of code.
66+
While this is perfectly fine for when we develop, such commented-out section should not make it into the PR.
67+
Code is either needed or it is not.
68+
69+
However, there are of course exceptions to this rule.
70+
If you think that a commented-out section of code should be left there for whatever reason - note it!
71+
Simple add a comment at the beginning of this explaining why is this code commented-out and why is it staying: ``# The code blow is commented-out but we decided to keep it because ...``
72+
73+
This will significantly ease the work of the reviewer when they see such sections.
74+
75+
Releases and versioning
76+
=======================
77+
78+
At one point you will likely find yourself in a situation that you want to label the state of the code with a version.
79+
This is typically done when development milestone is reached.
80+
When using Git, this is done through tags.
81+
One can name a tag whatever they want.
82+
However, we recommend using `Semantic Versioning (SemVer) <https://semver.org/>`_ for naming tags.
83+
In short, this will make your tags (labels) look like this: ``MAJOR.MINOR.PATCH`` (i.e. ``1.2.3``).
84+
If you prefer, you can add the ``v`` prefix: ``v1.2.3``.
85+
86+
One benefit of using tags (or versions) is dependency handling.
87+
Some other components of your project might depend on a specific version of your code.
88+
Using tags allows you to easily point to a specific state of the code.

0 commit comments

Comments
 (0)