I know that you can use
git commit --allow-empty
to put a commit with no actual file changes into the repository.
The problem I have is that I need to be able to create such empty commits that are associated with various file(s) in the repository. In other words, I want to be able to put in some empty commits for which
git log -- <filename>
will display the commit, but I can't figure out a way to do this.
Thanks!
Git makes this process of pushing an empty commit super simple. It's like pushing a regular commit, except that you add the --allow-empty flag. You can see that the commit has been pushed to your branch without any changes after running the above commands.
Creates an empty commit. Use git commit --allow-empty -m <message> to create an empty commit with the provided <message> .
git can't push empty directories. It can only track files.
From git log --help
:
[--] <path>...
Show only commits that affect any of the specified paths.
You want git log <path>...
to show a commit that does not affect the specified paths. That's not going to happen.
What you can do, however, is put the filenames in the commit message and then use git log --grep=<filename>
.
Maybe you do not want it in the commit message? Then put it into the commit notes: git notes add -m <filename>
. You may have to write a small script to grep for notes, but git plumbing should make that fairly easy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With