-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?

2
  • 1
    Not a duplicate, more like a help request to find the most efficient substitute. Commented Oct 2, 2015 at 1:14
  • @spirographer indeed! Commented Oct 2, 2015 at 2:15

3 Answers 3

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:

2
  • This looks like the most efficient approach given the GitHub interface. None of the other questions you linked to had nice workarounds like this. Commented Oct 2, 2015 at 1:26
  • The linked questions do not offer solutions. Thanks for your answer, I ended up making a chrome extension based off it: stackoverflow.com/a/32904508/469777 Commented Oct 3, 2015 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
1
  • 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 to do it anyhow. Commented Oct 3, 2015 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

2
  • I love how easy the extension works! I gave it 5 stars in the chrome web store. Commented Oct 4, 2015 at 21:07
  • 1
    @spirographer it was pretty easy to write too, so I'm sure github will at some stage do it themselves :) Commented Oct 5, 2015 at 0:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.