This is a summary of several Stack Overflow discusses about how to get the "diff" or the patch for the very first commit in Git.
- To get the diff from the very first commit to the empty tree, we can use the following command.
git diff \ 4b825dc642cb6eb9a060e54bf8d69288fbee4904 \ $(git log --reverse | head -1 | cut -d' ' -f2)
4b825dc642cb6eb9a060e54bf8d69288fbee4904
is the SHA of the empty tree and$(git log --reverse | head -1 | cut -d' ' -f2)
retrieves the SHA of the very first commit. Alternatively, we can rewrite the above in a way that perhaps is easier to read. - To get the diff from the very first commit to the empty tree, we can use the following command.
git diff \ $(printf '' | git hash-object -t tree --stdin) \ $(git log --reverse | head -1 | cut -d' ' -f2)
- To get the patch from the very first commit to the empty tree, we can use the following command.
git format-patch \ --root --stdout \ $(git log --reverse | head -1 | cut -d' ' -f2)
No comments:
Post a Comment