tags:

views:

489

answers:

2

Do you have a clean way to list all the files that ever existed in specified branch?

thanks

A: 

You can run git-log --name-status, which echoes something like:

commit afdbbaf52ab24ef7ce1daaf75f3aaf18c4d2fee0
Author: Your Name <[email protected]>
Date:   Tue Aug 12 13:28:34 2008 -0700

    Added test file.

A       test

Then extract files added:

git-log --name-status | sed -ne 's/^A[^u]//p' | sort -u
strager
+4  A: 

Variation on Strager's:

git log --pretty=format: --name-status | cut -f2- | sort -u

Edit:

Thanks to Jakub for teaching me a bit more in the comments:

git log --pretty=format: --name-only --diff-filter=A | sort -

Shorter pipeline, more opportunity to git to get things right.

Dustin
Hmm, I guess yours is superior. +1. =]
strager
whao, awesome, and fast!thank you!
elmarco
Hmmmm. using "uniq -u" may be faster and more memory efficient than "sort -u" if you don't actually want the output sorted. Could make a difference on big repos.
Pat Notz
@Pat: uniq requires sorted input, so you have to use sort
Jakub Narębski
@Dustlin: Add --diff-filter=A option (list only added files). Current version (without sed filtering only added files) would fail if you have enabled rename detection and have renames in history. I think you can then use --name-only instead of --name-status and remove 'cut -f2-' from pipeline.
Jakub Narębski