greetings everyone and Welcome to a new episode of SimiColon series Today we’ll complement talking about git We talked in the first two episodes The first episode introduction and how git very important. The second episode how we work as a contribution in gitHub “OpenSource Project”. The third episode we’ll complete in the same direction what’s the best way to write commit messages? This topic is very important for many reasons One of these reasons
If you remember the previous episode we talked about contribution guideline
Often it is written in the way that the owner of the repo needs to see this commit messages You’re dealing with it as an email when you need to send an email to the repo owner this email consists of:
Title and body which contains all the details you have done and why you did it? so that when the owner see this email ” commit message” can understand what you have done and then see your code if it displayed correctly or not, in the same Convention or not and then he can approve your commit Most of us are dealing with messages as some words For example, when we’re doing some changes in some files, only write commit message: some changes or some enhancements or test or test2 or test3 or fix then commit i’ll talk today about 5 steps to enhance your commit message Rule 1 include only the files related to the feature you are implementing. for example, You need to solve a problem in a model or DataBase connection and after fixing it, you found other files need to modify or delete, then you fixed the right thing, every commit should be related to the feature you are implementing. Rule 2 commit subject should be concise & reflect the essence of the commit for example,when you need to add a new component this component consists of more details, enhancements in Module the commit should be like that: subject: Add a new component this subject should be summarised and maximum 50 char it’s allowed to be more than 50 char but we’re talking about best practice then empty line Rule 3: commit body should include all the details of the changes you made and how details or body you can write it as a paragraph or lists of points I prefer lists Rule 4: Link your commit. Any commit or feature or task we’re doing must be linked to the board of tasks For example,this issue “Add readme file ” has a number #2 it’s important to reference this number in your commit, this number does reference to github or bitbucket which has this option Ref #2 or close #2 or fix #2 Ref #2 does reference only add a commit on the issue close #2 or fix #2 close the issue after merging commit Rule 5: always make the commit message verbal “start with a verb” any commit subject should start with a verb and it’s preferred imperative or past or present continues. example: Add – Added – Adding if you ask every message “what did you do?” it will answer ” Added …….. or “what are you doing ?” it will answer ” Adding ……..
and so on but the standard in git
you should reply or complete this sentence “if applied, this commit will ………” then your your commit message For example, “if applied, this commit will some changes”. “if applied, this commit will initial code” “if applied, this commit will tests” all of these not true. it should be a verb “if applied, this commit will Add readme file ” “if applied, this commit will Enhance CSS code ” Revision 1- include only the files related to the feature you are implementing. 2- subject should be summarised and maximum 50 char. 3- list all details inside the body. 4- link the issue to your commit . by adding: fix #issueNumber or close #issueNumber 5- commit message should apply to the form .
“if applied, this commit will ………” Example, i added some details in the readme file, renamed folder and added a folder called “episode 14” Rule 1: is there any file not necessary or not listed in commit? No Rule 2: Does the topic exceed 50 char? No empty line Rule 3: did you list all changes? yes Rule 4: did you do refer to the issue ? yes fix #2 after merging the issue will close automatic . Rule 5: is the subject or commit message apply the same idea? yes “if applied, this commit will Enhance readme file” so simple don’t forget to make the first letters in all commit messages Capital don’t forget to share and like see you next week 🙂