Good commits are well documented and allow you to understand the chronology of the project at a glance and thus facilitate the search. This is why GitHub allows us to commit issues within the message of a commit Did you know that you can close an issue in a commit? You can also mention users and even other commits.
To mention or referencing a user within a commit, just type
@username(in username the user we want to mention is used)
@jhon colaboró en esta parte.
To mention an issue, a hashtag is used followed by an id:
Trying to solve the problem #33.
You can even close an issue or several in a commit using keywords:
close closes closed fix fixed fixes resolve resolves resolved
it’s advisable writing messages of the commits in English to be consistent with the keywords. So for example if the commit does not solve the problem but it is decided to close the commit it is understood to use the keyword ‘close, closes or closed’, if the issue is a bug and the commit solves the error it would be better to use the keywords ‘fix, fixes or fixed’ and if it is a required improvement it can be use ‘resolve, resolve or resolved’ all keywords also close the referenced issue.
In case of being an issue to be closed:
This Closes #123
If the case of close an issue from another repository we should use this syntax
This Closes example_user/example_repo#76
Also we could close multiples issues in just one commit (maybe is not the best idea always)
This closes #34, closes #23, and closes example_user/example_repo#42
Finally, we can make reference o mention another commit using the md5 hash
e87947412f9b80d1c89e71541f8322a822301245 this also works and looks like this.
What about adding emotions to ours commits? we can also use emojis in the message with the syntaxis
to see all the availables emojis, yo can go to the Emoji cheat sheet.
There are many things that we can do with git and github but relating using commits has helped me a lot. I hope it is also useful for you.
All this also applies if you use Gitlab, you can go to the docs from gitlab and learn more tricks.