Composing a commit message without actually committing

I would like to open a normal editor for a commit message without actually creating the commit after editing. It should offer a post filled with normal information git status

and complete git diff

, which are deleted again after editing. The resulting text will be transmitted later git commit-tree

.

So essentially I am looking for something like

git commit -eF proposed-message.txt -v --cleanup=default

      

which does not create a commit, but instead prints a commit message to stdout or leaves it in a file for later use. Is there some kind of git subcommand that can help me with this?

+3


source to share


1 answer


You can use the hook-commit-msg hook to accomplish what you want by copying the commit message file somewhere and then commit fail. You can run the editor on a file to simulate what git would do if the hook failed (just run $(git var GIT_EDITOR) "$1"

, see git-var ). Of course, you will need to reverse this action somehow, perhaps via an environment variable, for example, so that it does not affect normal commits.



Typically, this complexity is a bad idea. See the linked StackOverflow post in Jubobs comment .

+1


source







All Articles