Get collections of diffs
I have project on开发者_如何学编程 github.com. All summer i made commits. Now i need to get all pathes.
I know that i can:
git log -p > project.path
But this variant write all pathes in one file. How can i make:
I have 3 files in github repository:
test.c
test1.c
test2.c
How can i get 3 files with all pathes?
test.diff
test1.diff
test2.diff
Thank you
You can use git format-patch
to create a sequence of patches from your commits (one patch per commit).
I can't think of any real automated way of doing it, but this worked for me on a unix system.
To start you need to have the ID of the first commit in your project, lets pretend it's 123abcd
(does anyone know of an automated way to get this?).
Once you have the id of the first commit you can just loop over the files that have changed since the first commit and run a diff on each one:
for file in `git diff --name-only 123abcd`; do
git diff 123abcd ${file} > `basename ${file}.patch`
done
What it all means:
git diff --name-only 123abcd
Will give you a list of any files that have changed since revision 123abcd
git diff 123abcd ${file} > `basename ${file}.patch`
Generates the actual diff and saves it into the name of the file without the path to it.
When you're finished your current working directory should hold all your .patch files.
精彩评论