-2

If I have browsed to a file on a commit that moved the file, what is the easiest way to navigate to the previous commit and location of the file?

For example, see the commit history on this file. The last entry on September 17 is the commit where the file was moved. To find its previous location, I did the following:

  1. Noted the initial commit date
  2. Went to the front page
  3. Clicked on commits
  4. Paged through to September 17 and found the commit
  5. Clicked on the commit prior
  6. Clicked Browse Files
  7. Hit T to open the file finder
  8. Typed HtmlHelper.cs
  9. Click the first result

Is there a more direct way to do this using github webpages?

Stafford Williams
  • 9,696
  • 8
  • 50
  • 101

3 Answers3

1

Yes you can do this, sadly it is pretty crappy with GitHub interface:

  1. Go to the file

Then you repeatedly do the rest of these until you are back as far as you wanted to go:

  1. Go to History

  2. Go to oldest commit of the list

  3. Note where file was moved from, in this case

    src/Microsoft.AspNet.Mvc.ViewFeatures/{Rendering/Html → ViewFeatures}/HtmlHelper.cs
    
  4. Go to parent commit

  5. Go to Browse files

  6. Browse to old location of file

It should be noted that your question is a duplicate, twice over:

Community
  • 1
  • 1
Zombo
  • 1
  • 62
  • 391
  • 407
  • This looks like the most efficient approach given the GitHub interface. None of the other questions you linked to had nice workarounds like this. – spirographer Oct 02 '15 at 01:26
  • The linked questions do not offer solutions. Thanks for your answer, I ended up making a chrome extension based off it: http://stackoverflow.com/a/32904508/469777 – Stafford Williams Oct 03 '15 at 10:44
0

This may be faster:

Starting from the commit history of the file:

  1. click on the earliest commit (last in sequence)
  2. click on the changed files to see the list
  3. search the filename, and navigate until you find it
  4. the list shows the transform from previous filename to current filename
  5. manually copy that older filename
  6. view commit history of the previous filename
  7. click on the second most recent commit

There does not seem to be an automatic way to do this in GitHub but the following post shows you how to do it on the command line:

http://thisbythem.com/blog/preserving-history-when-renaming-files-in-git/

git log --follow HtmlHelper.cs
spirographer
  • 630
  • 4
  • 18
  • 1
    Yeah, no problem doing this on the command line, but I often browse other repo's on github that I don't have locally. Ended up making an [extension](http://stackoverflow.com/a/32904508/469777) to do it anyhow. – Stafford Williams Oct 03 '15 at 10:46
0

I ended up making a chrome extension to make this a one-click effort based off the other answers:

Github Follow Extension

Stafford Williams
  • 9,696
  • 8
  • 50
  • 101