Skip to content

Commit 904c85f

Browse files
authored
Merge pull request akanshgulati#2 from akanshgulati/better-desc
docs(README): add commit-message section
2 parents 5376756 + bf5ba37 commit 904c85f

File tree

1 file changed

+50
-17
lines changed

1 file changed

+50
-17
lines changed

README.md

Lines changed: 50 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ These are **custom git commands** that encourages the git user to write formatte
1515

1616
More shorter way possible now:
1717

18-
e.g. ```gf feat install.sh 'Added commit semantics aliases'``` -> ```git commit -m 'feat(install.sh): Added commit semantics aliases'```
18+
e.g. ```gf install.sh 'Added commit semantics aliases'``` -> ```git commit -m 'feat(install.sh): Added commit semantics aliases'```
1919
## Installation
2020

2121
1. Clone this repo, preferably in your $HOME directory. ```git clone [email protected]:akanshgulati/commit-semantics.git
@@ -36,27 +36,28 @@ Once you install, you can use 10 git aliases in following ways:
3636
**```git <type> <scope> <commit-message>```** -> **```git commit -m '<type>(<scope>): <commit-message>'```**
3737

3838
e.g.
39-
* _**git feat** install.sh "added options feature"_ __->__ _git commit -m 'feat(install.sh): added options feature'_
40-
* _**git docs** readme "updated usage section"_ __->__ _git commit -m 'docs(readme): updated usage section'_
41-
* _**git chore** package.json "Added task for uglify"_ __->__ _git commit -m 'chore(package.json): added task for uglify'_
42-
* _**git fix** app "maximum call stack issue"_ __->__ _git commit -m 'fix(app): maximum call stack'_
43-
* _**git refactor** MainController "removed duplicate code"_ __->__ _git commit -m 'refactor(MainController): removed duplicate code'_
44-
* _**git style** input.scss "added secondary styling"_ __->__ _git commit -m 'style(input.scss): added secondary styling'_
45-
* _**git test** appSpec "fixed test cases for code changes"_ __->__ _git commit -m 'test(appSpec): fixed test cases for code changes'_
46-
* _**git perf** main.js "minified and bundled abc.js and def.js"_ __->__ _git commit -m 'perf(main.js): minified and bundled abc.js and def.js'_
47-
* _**git cleanup** dateFilter "removed never executable code"_ __->__ _git commit -m 'cleanup(dateFilter): removed never executable code'_
48-
* _**git tracking** sidebar "clicks on links"_ __->__ _git commit -m 'tracking(sidebar): clicks on links'_
39+
* _**git feat** install.sh "options in alias command"_ __->__ _git commit -m 'feat(install.sh): options in alias command'_
40+
* _**git docs** LICENSE "update to apache 2.0 style"_ __->__ _git commit -m 'docs(LICENSE): update to apache 2.0 style'_
41+
* _**git chore** package.json "task to uglify JS"_ __->__ _git commit -m 'chore(package.json): task to uglify JS'_
42+
* _**git fix** app "maximum call stack issue"_ __->__ _git commit -m 'fix(app): maximum call stack issue'_
43+
* _**git refactor** MainController "change callbacks to promises"_ __->__ _git commit -m 'refactor(MainController): change callbacks to promises'_
44+
* _**git style** navbar "add sticky position"_ __->__ _git commit -m 'style(navbar): add sticky position'_
45+
* _**git test** appSpec "fix test cases for init method"_ __->__ _git commit -m 'test(appSpec): fix test cases for init method'_
46+
* _**git perf** accordion "add lazy load in thumbnails"_ __->__ _git commit -m 'perf(accordion): add lazy load in thumbnails'_
47+
* _**git cleanup** dateFilter "remove unused dateChange method"_ __->__ _git commit -m 'cleanup(dateFilter): remove unused dateChange method'_
48+
* _**git tracking** sidebar "add click event on links"_ __->__ _git commit -m 'tracking(sidebar): add click event on links'_
4949

5050
2. __Committing with options__
5151
* **```git <type> <scope> <commit-message> [options]```** -> **```git commit [options] -m '<type>(<scope>): <commit-message>'```**
5252

5353
e.g.
54-
* _**git feat** install.sh "added options feature" a_ __->__ _git commit -a -m 'feat(install.sh): added options feature'_
55-
* _**git fix** app "maximum call stack issue" p_ __->__ _git commit -p -m 'fix(app): maximum call stack'_
54+
* _**git feat** install.sh "options in alias command" a_ __->__ _git commit -a -m 'feat(install.sh): options in alias command'_
55+
* _**git fix** app "maximum call stack issue" p_ __->__ _git commit -p -m 'fix(app): maximum call stack issue'_
5656

5757
**Note:** Only those options can work that precedes `-m` option in git commit, such as `-p`, `-a`, `-s`, `-v`, `-c` .
5858
## Guidelines
5959
### Selecting `type`
60+
____
6061
Different types of `type` are there according to make sure one can get idea about the core reason of commit message. Current script supports following types of commits.
6162

6263
* **feat**: Commits related to a new feature developed
@@ -73,15 +74,47 @@ generation
7374
* **docs**: Commits related to documentation changes, such as Readme.md file
7475

7576
### Selecting `scope`
76-
77+
____
7778
The scope in commit message could be anything specifying context of the commit change. A scope context can be a `module`,
7879
`fileName`, `serviceName`, `directiveName`, `functionName` , `impactArea`, etc.
79-
80+
### Selecting `commit-message`
81+
____
82+
There are certain rules that everyone should follow to commit like a pro.
83+
1. [**Limit of 50 characters**](#heading-message-one)
84+
2. [**Do not end the message with a period**](#heading-message-two)
85+
3. [**Use imperative form**](#heading-message-three)
86+
4. [**Use present tense**](#heading-message-four)
87+
88+
#### <a name="heading-message-one"></a> 1. Limit of 50 characters
89+
50 characters is not a hard limit, just a rule of thumb. Keeping message at this length ensures that they are readable, and forces the author to think for a moment about the most concise way to explain what’s going on.
90+
Even Github truncates any message line longer than 72 characters with an ellipsis.
91+
> If your message length increases 50 characters even after summarizing, try to adopt atomic commits pattern. You can use `git add -p` to get better insight of changes.
92+
93+
#### <a name="heading-message-two"></a> 2. Do not end the message with a period
94+
Punctuation marks at the end of message is not required as commit messages are considered as subject or titles.
95+
#### <a name="heading-message-three"></a> 3. Use imperative form
96+
Imperative form ensures to convey the correct instruction of the commit in short and crisp form. With the current commit semantics, keeping imperative form is much easier.
97+
Few examples:
98+
* Pour me a glass of water.
99+
* Leave the package at the door.
100+
* Take me to the library.
101+
102+
You can read more about imperative form [here](http://www.k12reader.com/learn-about-imperative-sentences-now/).
103+
#### <a name="heading-message-four"></a> 4. Use present tense
104+
Usually, we believe commit message records what we have done. But, Git is a distributed version control system where there are potentially many places to get changes from. Rather than writing messages that say what you’ve done; consider these messages as the instructions for what applying the commit will do.
105+
106+
For example:
107+
108+
`Renamed the variabled for better context` should be `Rename the variabled for better context`
109+
110+
Even Git generated commit messages are in present tense. For example:
111+
112+
`Merge pull request #1 from akanshgulati/better-desc `
80113
## Example
81114

82115
##### **Command**:
83-
git refactor header 'change z-index'
116+
git style header 'move header on top of elements'
84117
##### **Output**:
85-
git commit -m "refactor(header): change z-index"
118+
git commit -m "style(header): move header on top of elements"
86119

87120

0 commit comments

Comments
 (0)