I have lost access to laptop where I pushed only the merged branch (onto master) but forgot to update the branch itself.
So I tried the following little experiment:
$ mkdir g
$ cd g
$ git init
$ echo 1 >> README.md
$ git add README.md
$ git commit -m"First commit" -- README.md
$ git checkout -b b1
$ echo 2 >> README.md
$ git commit -m"Second commit" -- README.md
$ git checkout master
$ git merge b1
$ git checkout b1
$ git reset --hard HEAD~
$ git cherry-pick 365163b00fee76cdc6d3e34b139b0ed42b184437
The above does not re-create commit 365163b00fee76cdc6d3e34b139b0ed42b184437 identically but create another one (d6debaa050c5).
What is the right command to recreate a commit from an existing commit onto a branch (no access to reflog) ?
For my specific need, I can check that I do have the following informations:
$ git show --pretty=fuller 365163b00fee76cdc6d3e34b139b0ed42b184437
commit 365163b00fee76cdc6d3e34b139b0ed42b184437
Author: Mathieu Malaterre <example@example.org>
AuthorDate: Tue Feb 25 14:02:06 2020 +0100
Commit: Mathieu Malaterre <example@example.org>
CommitDate: Tue Feb 25 14:02:06 2020 +0100
Second commit
diff --git a/README.md b/README.md
index d00491fd7e5b..1191247b6d9a 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,2 @@
1
+2
- Branch b1 has not changed, so parent sha1 is correct,
- commit information is correct (message, author, committer and timestamp).