Git/hacks: Difference between revisions

No edit summary
Line 159: Line 159:


==Good and Consistent commit messages==
==Good and Consistent commit messages==
You hopefully know what constitutes a [https://cbea.ms/git-commit/ good] [https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html commit message].
You hopefully have read 


https://thoughtbot.com/blog/5-useful-tips-for-a-better-commit-message
* [https://cbea.ms/git-commit/ How to write a good commit message]
* Tim Pope's [https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html Note about git commit messages].
* and maybe [https://thoughtbot.com/blog/5-useful-tips-for-a-better-commit-message 5 useful tips for a better commit message]<ref>I disagree with tip #3
 
You can use -m on the CLI. You can absolutely have a subject and body in your message - you just have to be careful with quotes. However, it ''is'' easiest to use an IDE, or .vimrc</ref>


===Seven Habits of Highly Effective People (committers) ===
===Seven Habits of Highly Effective People (committers) ===
Line 174: Line 178:
===Keywords===
===Keywords===
Start your subject with one of the "agreed" keywords for your project so you can easily see them in the [[Git/log]] to make [[RELEASE NOTES]] easy.
Start your subject with one of the "agreed" keywords for your project so you can easily see them in the [[Git/log]] to make [[RELEASE NOTES]] easy.
  add|bug|chore|delete|doc|feat|fix|refactor|remove|style|test|update
  Add|Bug|Delete|Doc|Feat|Fix|Refactor|Remove|Style|Test|Update
What are the keywords your project uses?
 
<code>git log --pretty=format:"%s" --no-merges | awk '{print tolower($1)}' | sort | uniq -c | sort -nr | head -20</code>
 
*     233 add
*    200 fix
*     84 update  
*     81 make
*     67 remove
*     61 use
*     45 bump
*     38 change
*     31 move
*     31 don't
*     29 allow
*     24 [skip
*     22 more
*     20 need
*     17 fix:
*     15 upgrade
*     14 specify
*     14 set
*     13 fixes
*     13 enable


===Boilerplate===
===Boilerplate===
Line 182: Line 210:
To consistently format your commit messages, use the configuration parameter <code>commit.template</code> which you can do with <code>git config</code>, or else in your ~/.gitconfig file. Here's my [[Git/commit.template|commit.template]]
To consistently format your commit messages, use the configuration parameter <code>commit.template</code> which you can do with <code>git config</code>, or else in your ~/.gitconfig file. Here's my [[Git/commit.template|commit.template]]


===Commit Templates===
===Commit Templates for Merges===
The GitLab project uses the concept of commit templates<ref>https://docs.gitlab.com/ee/user/project/merge_requests/commit_templates.html</ref>
The GitLab project uses the concept of commit templates for merge commits<ref>https://docs.gitlab.com/ee/user/project/merge_requests/commit_templates.html</ref>


==Comparing local to upstream==
==Comparing local to upstream==