How can I make a new commit and create a new message if no changes are made to files?
Is this not possible since the commit’s code (SHA ?) will be the same?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
There’s rarely a good reason to do this, but the parameter is
--allow-emptyfor empty commits (no files changed), in contrast to--allow-empty-messagefor empty commit messages. You can also read more by typinggit help commitor visiting the online documentation.While the tree object (which has a hash of its own) will be identical, the commit will actually have a different hash, because it will presumably have a different timestamp and message, and will definitely have a different parent commit. All three of those factors are integrated into
git‘s object hash algorithm.There are a few reasons you might want an empty commit (incorporating some of the comments):
gitcommands without generating arbitrary changes (via Vaelus).gitolite(via Tatsh).Other strategies to add metadata to a commit tree include:
git notesto associate a mutable note on top of an existing immutable commit.