6

I'm lost in a repo maze with a bunch of files that were readded while their older version was renamed because of a not-so-good rebase that was made.

Anyway, I want to list all the files that at some point were renamed, that is, list all renamed files from all commits.

Roberto
  • 11,011
  • 15
  • 53
  • 66
  • `git log --follow` from [this question](http://stackoverflow.com/questions/5743739/how-to-really-show-logs-of-renamed-files-with-git) – johnMa Dec 19 '13 at 02:36
  • sorry, no, I want to list *all* files that were changed in all commits, `--follow` only works for a single file. – Roberto Dec 19 '13 at 02:59
  • It sounds like you are in an icky situation. Are you able to use `git reflog` (or a branch, or something) prior to the rebase and redo your commits from there so you aren't in this position? – James Dec 19 '13 at 04:07

2 Answers2

4

Would this suffice?

git whatchanged -M5 --summary | grep rename | grep '=>'

Here is a modified version which will do renamed and deleted files:

git whatchanged -M5 --summary | grep -E 'rename.*=>|delete mode'

This will give you all renames from the HEAD of your current branch and it's ancestry including merged parents up to the very first commit. The -M5 will have files that are similar by 50% or more reported as a rename; this may be to low of a percentage but you can change it (The 5 is read as .5, or 50% so you could change it to M8 for 80%). Be warned, it will take a long time if there are a lot of commits.

I suggest you limit the range of commits such as:

git whatchanged -M5 --summary <commit-id>..HEAD | grep rename | grep '=>'

As far as I can tell you will need to start with a commit, I am not sure how you could get a comprehensive list of renamed files across all branches and tags at once. If you have divergent branches you want to check, or branches with independent commit histories in a single repo, you will need to run the suggested command on each branch.

James
  • 1,744
  • 13
  • 21
0

You should be able to get that info from the logs using --diff-filter option. The filter for renamed files is R, and D for deleted files.

Renamed files:

git log --summary --pretty='format:' --diff-filter=R

Deleted files:

git log --summary --pretty='format:' --diff-filter=D

Renamed + deleted files:

git log --summary --pretty='format:' --diff-filter=RD
Marcel Gongora
  • 395
  • 3
  • 5