This are my notes in the fields of computer science and technology. Everything is written with ABSOLUTE NO WARRANTY of fitness for any purpose. Of course, feel free to comment anything.

Tuesday, August 11, 2009

git: write a single commit to file

Write the commit to file:
git diff-tree <commit> -p --pretty > <filename>
You can also use git format-patch, but that is more specialized for patches to be submitted by email.

Apply the commit from the file:
git apply <filename>
Here is an excerpt from the git diff-tree manual page:
When "git-diff-index", "git-diff-tree", or "git-diff-files"
are run with a -p option, "git diff" without the --raw option,
or "git log" with the "-p" option, they do not produce the output
described above; instead they produce a patch file. You can
customize the creation of such patches via the GIT_EXTERNAL_DIFF
and the GIT_DIFF_OPTS environment variables

About Me

My photo
Hamburg, Hamburg, Germany
Former molecular biologist and web developer (Rails) and currently research scientist in bioinformatics.