Aaron Anodide
Aaron Anodide

Reputation: 17196

git noob: how to copy just the updated files to a target directory?

I'm using Git for an ASP.net site.

I push changes to the repo.

Then I go to the server, fetch from repo and merge local.

--> Now, I just want to copy the files that have changed over to my Inetpub folder.

Is there an easy way to do this with a Git Bash command?

Upvotes: 1

Views: 59

Answers (1)

shelhamer
shelhamer

Reputation: 31170

git show --pretty="format:" --name-only HEAD

Gives you the files that were changed in the latest commit in a one-file-per-line list. HEAD can be replaced by any git treeish, such as a commit sha1 or HEAD^ for the parent of the latest commit, etc.

You directly use this to copy files by piping it to xargs and copy using either the -J or -I switch for OS X and linux respectively:

git show --pretty="format:" --name-only bd5b6d356374e2cd64250f68c94e3a1738592a9f | xargs -I % cp % destination_folder

Upvotes: 3

Related Questions