[NSWI004] Several notes on Git, GitLab and CI

Vojtech Horky horky at d3s.mff.cuni.cz
Mon Nov 9 06:50:40 CET 2020


Hello,

just few notes in no particular ordering.

It is possible to setup your Git commit identity (e-mail) in GitLab 
instead of the default one.

When you are using Git for the first time on a given machine (e.g. 
lab.d3s.mff.cuni.cz or Rotunda servers), you should set your Git name 
and e-mail via "git config" command (probably with the --global switch). 
Note that Git will warn you during every commit that you have not done so.

It is a good practice to always commit code that compiles. For 
master/main branch, the rule is usually to commit code that compiles and 
passes the tests.

GitLab CI is not your development environment. You are supposed to 
develop, debug and test on your machine and push to GitLab only 
reasonable commits. There is no reason to push every single commit to 
GitLab to see whether it compiles.

As a matter of fact, if you commit/push every minute to debug your 
knowledge of C syntax and/or for every word in one code comment, two 
things may happen. We may consider this as a gaming of the activity 
points. And we might be forced to setup some type of accounting for the 
use of CI to ensure fairness (I already received a complaint from GitLab 
administrator about overloading the CI machines).

Note that it is completely fine and highly recommended to create very 
small, focused commits but each commit should represent a 
compact/logical/atomic change of your project. Think always about a 
reviewer that clicks on your commit - are there only changes related to 
the topic and are there all the changes related to the topic?

Note that "git add -p" allows you to split big change into multiple 
commits quite easily.

As a further reading, I would recommend [1] about good commit messages 
and perhaps [2] as well as it reiterates some notes about committing in 
general.

[1] https://chris.beams.io/posts/git-commit/
[2] 
https://koukia.ca/git-some-commit-best-practices-and-how-to-undo-your-recent-commits-d13c9dc3144f

Hope this helps,
- VH


More information about the NSWI004 mailing list