views:

43

answers:

1

Hi all!

I am very new to Git and I have a slight problem.

In SVN [this feels like an Only Fools and Horses story by uncle Albert.."during the war..."] when I wanted to update a production site with my latest changes, I'd do a diff in TSVN and export all the changed/added files between two revisions. As you can imagine, it was easy to get those files to a production site afterwards.

However, it seems like I'm unable to find an "export changed files" option in Git. I can do a diff and see the changes, I can get a list of files, but I can't actually export them. Is there a reasonable way to do this? Am I missing something simple?

Just to clarify once again, I need to export all the changes between two specific commits.

Thanks in advance!

+3  A: 

How do you want to export them? You say you already have a list; what more do you want? Supposing you're getting your list with git diff --name-only ...

git archive --output=<file> HEAD $(git diff --name-only ...)

tar -czf <file> $(git diff --name-only ...)

cp $(git diff --name-only ...) <export-directory>

Something like that?

Or you could even use the diff itself - it can be applied with git apply (or even patch, I believe).

Jefromi
The first option is working for me! Ideally, I would use the cp variant but keep the folder structure (I'm guessing it's a matter of parameters for git diff?) I can't believe it's that simple..thanks!
dr Hannibal Lecter
Just saw your edit.. Unfortunately, I can't use `git apply` or `patch`, I only have FTP access to the site :-/
dr Hannibal Lecter
@dr Hannibal Lecter: Yeah, I figured you needed to pass around actual files. And yeah, command substitution (the `$(...)`) is one of those key things that makes everything possible (and simple) in Linux shells.
Jefromi
Sadly, I'm currently 50% stuck on Windows, but git bash and cygwin tend to make my life easier.. even though I often have no idea what I'm doing :) Thanks again for the useful info!
dr Hannibal Lecter
@Jefromi: How would you make a diff ignoring files with only modified permissions and not modified contents?
Cesar