user image

Shilpa
Published in : 2022-03-02

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 Date : 2022-03-02

Best answers

8

Best answers

8

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 Date : 2022-03-05

Best answers

34

Best answers

34

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.

Leave a comment

Join us

Join our community and get the chance to solve your code issues & share your opinion with us

Sign up Now

Related posts

Is there any port I need to allow in google VM instances to allow SMTP?
Publish date: 2022-02-14 | Comments: 1

Tag: General

Convert Stored Procedure of Oracle to SQL Server
Publish date: 2022-03-02 | Comments: 1

Tag: General

Help with sliding an image from the top of a stack
Publish date: 2022-02-12 | Comments: 1

Tag: General

Where can I find cheap Java and Mysql hosting server?
Publish date: 2022-05-03 | Comments: 3

Tag: General

Keycloak db query in source codes [closed]
Publish date: 2022-03-05 | Comments: 0

Tag: General

Searching for free live chat service
Publish date: 2022-02-11 | Comments: 2

Tag: General