31

After renaming a folder (git mv foldername newfoldername) the history of this folder in Github has gone. I can still view the full history of any file in the folder if I clone the repro and run...

git log --follow ./newfoldername/file

But is it possible to get history for renamed folders visible in Github? This is a Github question, the git revision history is working as expected. Thanks

ErikE
  • 48,881
  • 23
  • 151
  • 196
Patrick Clancey
  • 1,330
  • 1
  • 14
  • 22
  • Since it doesn't pertain to Git per se, I changed the title. Also, file/dir-level history isn't really *tracked* in Git, it's rather *reconstructed*. If GitHub could do this reconstruction the way you wanted, you'd probably have seen it already. – Fred Foo Jun 20 '13 at 12:13
  • 4
    Note that Git does not explicitly track renames of files (a renamed file results in its old entry missing from the next tree object representing that file's directory, and the new entry added to it), and renaming of a directory results just to the single change to an appropriate entry to a tree object representing the state of an enclosing directory. As @larsmans correctly points out, renames are *guessed* by the `git log` machinery (which has several knobs to affect this). So I'd not hold my breath to have a proper solution to your problem. – kostix Jun 20 '13 at 12:14
  • Note also that `git` doesn't track history for folders at all, beyond the notion of "this file lives in this folder in this particular tree/commit"... – twalberg Jun 20 '13 at 15:26
  • Possible duplicate of [How to make github follow directory history after renames?](http://stackoverflow.com/questions/5646174/how-to-make-github-follow-directory-history-after-renames) – Ciro Santilli OurBigBook.com Mar 12 '17 at 07:39

3 Answers3

16

Edit

This extension is no longer needed as this answer shows GitHub now implements this functionality natively

Previous

I wrote a chrome extension to enable this. Source on github.

Github Follow Extension

Stafford Williams
  • 9,696
  • 8
  • 50
  • 101
  • Bit of an older thread, but are you maintaining this? Because it doesn't seem to work currently :( Here's a commit with a few moves: https://github.com/Rene-Sackers/gta-network-typescript/commit/f61486b6b456830c8ea3f648c325fb26186326ea – René Sackers Apr 11 '17 at 16:33
  • You need to be looking at the history of a file rather than a commit, e.g: https://github.com/Rene-Sackers/gta-network-typescript/commits/f61486b6b456830c8ea3f648c325fb26186326ea/content/types-gtanetwork/Declarations.d.ts – dsturbid Apr 27 '17 at 16:29
  • 11
    Why on EARTH is this something that needs a _browser extension_ ?!? – Alex McMillan Jun 07 '17 at 22:35
  • Doesn't work anymore, apparently: https://github.com/Rene-Sackers/gta-network-typescript/commits/master/content/types-gtanetwork/NativeUI.dll.d.ts – Dorian Marchal Apr 03 '19 at 12:21
  • 1
    @DorianMarchal I still see it: https://imgur.com/a/tHkeWQ9. If you don't see that, open an issue and I'll have a look - https://github.com/staff0rd/github-follow-extension/issues – Stafford Williams Apr 03 '19 at 19:47
11

You just need a commit before the rename happened. You could retrieve it locally or via the Blame feature.

After you have retrieved the URL of such commit you just need to click History. You will then see all of the commit history of the file before the rename.

Haralan Dobrev
  • 7,617
  • 2
  • 48
  • 66
2

This is now (June 2022, 9 years later) supported by GitHub:

View commit history across file renames and moves

When a file is renamed or moved to a new directory but half of it's contents remain the same, it's commit history will now indicate that the file was renamed, similar to git log --follow.

View commit history across file renames and moves

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250