user

Shilpa

2 Mar 2022

Is it possible to git commit files without adding a message or comments?

General

I am making code changes, where my development work is still ongoing, I want to push some files without adding a comment for those comment history.

Is it possible to commit a file excluding the message for the commit? Any other suggestions are also most welcomed to achieve this requirement!

Comments

Eslam Zedan

2 Mar 2022

you can commit with an empty comment but it is not a good practice you should comment your commit so you can know why you made these changes 

here is the code for the empty commit

git commit -a --allow-empty-message -m ''

Rakshit

5 Mar 2022

Best Answer

best answer

If you are not destroyer and want to do the things for good purpose, here is what you can use

in your git commit command, 

add parameter “--allow-empty” : No file changes

add parameter “--allow-empty-message”: Empty commit messages

Syntax: 

git commit [-a | --interactive | --patch] [-s] [-v] [-u<mode>] [--amend]
 [--dry-run] [(-c | -C | --squash) <commit> | --fixup [(amend|reword):]<commit>)]
 [-F <file> | -m <msg>] [--reset-author] [--allow-empty]
 [--allow-empty-message] [--no-verify] [-e] [--author=<author>]
 [--date=<date>] [--cleanup=<mode>] [--[no-]status]
 [-i | -o] [--pathspec-from-file=<file> [--pathspec-file-nul]]
 [(--trailer <token>[(=|:)<value>])…] [-S[<keyid>]]
 [--] [<pathspec>…]

Try below command to achieve your task,

git commit -a --allow-empty --allow-empty-message

Reference:  the online documentation.

© 2024 Copyrights reserved for web-brackets.com