Mebus
Mebus

Reputation: 71

Git: Check out all files that ever existed in a subdirectory?

Is there a way to check out all files that EVER existed in a git subdirectory?

(newer ones may overwrite older ones...)

Upvotes: 1

Views: 64

Answers (1)

John Feminella
John Feminella

Reputation: 311486

One way to do it is to list the names of all the files that were ever added:

git log --pretty=format: --name-only --diff-filter=A <some-directory> | \
  sort -u > /tmp/files.txt

Now you can checkout each one:

while read f; do git checkout "$f"; done < /tmp/files.txt

Upvotes: 1

Related Questions