0

I am trying to clone/pull, all the files pushed to remote repository, only on a specific date (say, after 2018-08-06). In my remote repository, i have more than 10000 files, but i only need files pushed to the repository, on a specific date. With the below command, i am able to see the logs for a specific time period:

git log --since=2018-08-03 --until=2018-08-06

Now i need to clone only these files and not all the files in the repository. Please suggest.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Aman
  • 159
  • 2
  • 15
  • **git log --name-status --since='3 August 2018' --until='6 August 2018' | grep -E '^[A-Z]\b' | sort | uniq | sed -e 's/^\w\t*\ *//'** Above command gives the list of filenames. – Aman Aug 06 '18 at 12:24
  • "clone/pull" Do you already have a clone of the remote repository? – kelvin Aug 06 '18 at 17:46

1 Answers1

0

There is no way to clone or fetch specific files, only git objects (e.g.: commits). Also, the changes to each file might be spread among several commits.

Clone

If you do not have a clone yet, make a shallow one:

git clone --depth 1 "$url"

Fetch

An option would be to identify locally all files that were modified on this date range:

files="$(git log --pretty='' --name-only --since="$since"
  --until="$until")"

Then, get every commit that touches those files:

revs="$(git log --pretty='%H' -- $files | sort -u)"

And fetch them:

git fetch $revs

Note: This is a naive approach and you might end up fetching a lot of commits either way.

kelvin
  • 1,421
  • 13
  • 28