Git Archive Based on Merged Date

238 Views Asked by At

I could know the merging dates of git checked in by using this command:

git log --after='2015-05-12' --merges

It would show git log of revision history after 12 May 2015.

Is there any way to combine this with git archive?

The objective is to:

Export all the modified files being merged after 12 May 2015 into one folder location.

Thank you in advance!

1

There are 1 best solutions below

1
On BEST ANSWER

Well, I think your objective can reached in the following steps:

  1. get the sha1 of the last merge commit: git log --after='2015-05-12' --merges --pretty=format:%H (there're simpler ways to do the same but nevermind)
  2. get the list of files being changed in the HEAD since that: git diff <sha1>..HEAD --name-only
  3. put the HEAD in the archive limiting the files by the list received on the previous step

If the number of files is small enough (i.e. it doesn't exceed the limit of command line parameters) the command looks like this:

git diff --name-only $(git log --after='2015-05-12' --merges -n 1 --pretty=format:%H)..HEAD | \
    xargs git archive --prefix changed/ -o some.tar HEAD