How to use git format-patch on initial commit
Asked Answered
D

3

27

I need to get patch file for inital commit (which is not empty) for our review process, but I'm confused as git format-patch command only makes it from branch that is on initial commit not including it.

Seems it must be some obvious move but I'm completely missing it.

Demagogue answered 25/6, 2012 at 21:44 Comment(0)
A
30

Try git format-patch --root $SHA (where $SHA is that first commit)

Ardellearden answered 25/6, 2012 at 21:53 Comment(1)
It works for getting a patch file from the first commit only. when getting patch files from all history, it requires two steps: 1) get a patch file from the initial commit, apply it. then gets patch files by running git format-patch ${SHA1_of_initial_commit)..HEAD, apply them.Gulledge
I
8

for making patch for a single commit just use

git format-patch -1 HEAD # where "1" is a number, not "ell".

where "HEAD" could be changed to any other commit, or even hash code. This works even if HEAD is the first commit. I am not sure whether you are asking for this.

Illgotten answered 24/7, 2012 at 14:26 Comment(0)
L
4

Maybe this has changed, but

git format-patch --root

just created all patch files including the initial commit and HEAD. My git version is 2.26.2.windows.1.

Liddie answered 31/3, 2021 at 10:5 Comment(1)
Yes! This is good. As the poster says, this does All COMMITS from initial commit through to the most recent I have just run this on git version 2.34.1.windows.1 Thank youEarthbound

© 2022 - 2024 — McMap. All rights reserved.