Yes, git show
has a -p
flag for this purpose.
git show -p abcd1234 > path/to/file.patch
It'll generate a text file (you can open it with any text editor) with a content in the following form (mind the metadata you wanted)
commit 8aab31565962f681639d0a7b6b5b8c0d3fe6b695
Author: John Doe <john.doe@corporation.com>
Date: Tue May 28 17:05:01 2019 +0200
Made some critical changes to function foo_bar
diff --git a/path/to/file b/path/to/file
index 8a443961df..5b5ad4726a 100755
--- a/path/to/file
+++ b/path/to/file
@@ -2620,6 +2620,6 @@ function foo_bar() {
/**
* Function documentation
*/
-function foo_bar() {
+function foo_bar() {
someFunction("param");
}
then you'll be able at some future point to apply the patch elsewhere with
git checkout someBranch
git apply path/to/file.patch
See the appropriate doc section for the details.