I have written a commit to a file from gitk by right-clicking the commit and selecting “Write commit to file”.
How do I apply the commit from this file? I can do git apply, git add and git commit combo, but isn’t there a one-step command to just take the output (with the commit message and meta-data) and commit it as it is?
I’m using Linux, but I think I see what you’re talking about. In
gitkthere is a “Write commit to file” option when right-clicking a commit, which brings up a dialog that performs the commandgit diff-tree --stdin -p --prettyby default.git applyis only for applying diffs, i.e. it won’t create the commit object so that shouldn’t be used.git amshould be the correct tool for performing this operation, as it creates commit objects. However, it doesn’t understand the format output by the above command, and creates the error you are seeing.The easiest option is probably to create the patch using a format
git amunderstands usinggit format-patchinstead ofgit diff-tree. There may be a way to coercegit aminto understanding thegit diff-treeformat, but I don’t do patches much so am not aware of it offhand.