startupsmith startupsmith - 1 year ago 68
Git Question

Git post-receive to checkout only those files that have been modified/added in the push?

I have been using post-receive scripts in my git repositories with the following commands to checkout all of the files in the repository:

GIT_WORK_TREE=/var/www/ git checkout -f

I am wanting to do something similar but only checkout the files that have been modified or added in the push. Once the files have been checked out the post-receive script will then run some other commands on these files and remove the files at the end so that the directory will be empty.

Is this possible?

Answer Source

you can use git diff to give you a list of files

git diff --name-only

in a post-receive hook that'll be I think

git diff --name-only $1..$2

as this hook receives oldrev, newrev and ref on standard input

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download