Home > other >  Extract all files changed in repo since a certain date
Extract all files changed in repo since a certain date

Time:11-05

I need to pull out all files changed since a certain date from my git repo to copy them into a separate repo.

Running the following grabs the list of file paths that I need:

git log --since="2021-10-21" --name-only --pretty=format: | sort > changed-files.txt

Manually copying this large list would be time-consuming and very error-prone.

Is there any way to extract or bundle this list of files to more easily move them?

CodePudding user response:

Something like this may be just what you want

git log --since="2021-10-21" --name-only --pretty=format: | \
sort -u | \
grep -ve '^$' | \
xargs -I{} cp -v -u {} /destination/path

features

  • sort -u eliminates duplicates
  • grep -ve '^$' eliminates any empty lines (there was one in my output)
  • xargs replace from cp after xargs not working
  •  Tags:  
  • git
  • Related