Question

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!

Was it helpful?

Solution

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).

OTHER TIPS

Borrowing from few of the answers in here, here is another way to export files that are modified in the workspace:

git diff --diff-filter=ACMRT --name-only HEAD | xargs tar -rf export.tar

You might need to execute the following beforehand to add untracked files, if you need to include them in the diff:

git add *

[This works in git-bash in Windows]

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top