This is a follow-up to this Q&A. The aim is to add an empty commit to a specific file, but it turned out that an actual change is required.
Steps to reproduce
- Navigate to a git repository
- run
git log - the git log will be displayed
- execute
git commit path/to/specific/file --allow-empty -m "Empty commit"
Expected outcome
- Issue
git log path/to/specific/file - The
Empty commitmessage will appear - The output of
git logdoes NOT contain theEmpty commit
Actual outcome
It turned out that the Empty commit resides in the root git log (git log) rather than in the specific file (git log path/to/file)
Discussion
AFAIK git log is a record of commits, which apply to every file in your repository
If one applies a change to path/to/some/file, adds and commits it and subsequently runs git log path/to/some/file then the commit message is shown, but when one issues git log path/to/some/another-file then the commit message is omitted.
Why do you think you need this?
There is a check that inspects whether the user of last commit is the CI user to ensure that there are no libraries that contain unreleased changes. Of course it is possible to add a superfluous space in order to add a new commit to a specific file, but it is preferred to add a new commit without changing the file.