TIL: git commit accepts several message flags (-m) to allow multiline commits
source link: https://www.stefanjudis.com/today-i-learned/git-commit-accepts-several-message-flags-m-to-allow-multiline-commits/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
When you use git on the command line you might have used the message flag ( -m
). It allows developers to define commit messages inline when calling git commit.
git commit -m "my commit message"
I'm not the biggest fan of this approach because I prefer to edit the commit message in vim (which I only use for writing commit messages). It gives me the opportunity to double-check the files I'm committing.
Today I learned that the git commit command accepts multiple message flags. :astonished:
It turns out that you can use the -m
option multiple times. The git documentation
includes the following paragraph:
If multiple -m options are given, their values are concatenated as separate paragraphs
If you run the following command
git co -m "commit title" -m "commit description"
it will result in this commit.
Author: stefan judis <stefanjudis gmail="" com=""> Date: Tue Jul 7 21:53:21 2020 +0200 commit title commit description test.txt | 0 1 file changed, 0 insertions(+), 0 deletions(-) </stefanjudis>
You can use multiple -m
flags to create "multiline commits", and I have to admit that this can be very handy in some cases.
If you want to see this command in action, I shared a short terminal session on Twitter with a little video .
Recommend
-
133
GIT: Some Commit best practices and How to undo your recent Commits
-
52
题注:如果喜欢我们的文章别忘了点击关注阿里南京技术专刊呦~ 本文转载自 阿里南京技术专刊-知乎,欢迎大牛小牛投递阿里南京前端/后端开发等职位,详见 阿里南京诚邀前端小伙伴加入~。 commit message 是开发的日常操作, 写好 log 不仅有助于他人
-
44
git-treesame-commit Utility to make new commits that are treesame with others. Every commit has a treehash , or...
-
48
【编者的话】Git是现在市面上最流行的版本控制工具,书写良好的commit message能大大提高代码维护的效率。但是在日常开发中由于缺少对于commit message的约束,导致填写内容随意、质量参差不齐,可读性低亦难以维护。在项目中引入commit m...
-
36
Git: Combine all messy commits into one commit before merging to Master branch Jump to bottom S...
-
39
How To Prefix Your Commit Message With a Ticket Number AutomaticallyPractical use-case for the prepare-commit-msg git hook
-
13
Allow commits from users who can commit to the target branch by default Allow commits from users who can commit to the target branch by default
-
6
How to Use Git Rebase to Squash a Sequence of Commits to a New Base CommitMay 4th 2021 new story10
-
1
Skype Insider update brings improved message quoting and several fixes for annoying bugs...
-
2
@autumnskerrittautumnWriter 👽Receive Stories from @autumnskerrittCredib...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK