Skip to content

Add "view file before commit/PR" #3289

Closed as not planned
Closed as not planned

Description

@OliverJAsh

When viewing a commit page, GitHub provides a link to view each file. The link points to the file at the current commit. Example.

However, sometimes we want to view the version of a file before the commit was made.

For the longest time I have been doing this manually, by clicking "view file" and then editing the URL to add a ^ at the end of the commit (to reference the parent commit).

It would be very useful if this was added as a link in the menu, so we don't have to resort to hacking the URL like this.

This would also be useful in PRs, where GitHub similarly shows a "view file" link for each file in the diff. Sometimes we want to view the version of a file before all of the commits in this PR.

Activity

  1. changed the title [-]Add "view file before commit"[/-] [+]Add "view file before commit/PR"[/+] on Jun 26, 2020
  2. yakov116 commented on Jun 26, 2020

    @yakov116
    Member

    For the longest time I have been doing this manually, by clicking "view file" and then editing the URL to add a ^ at the end of the commit (to reference the parent commit).

    What about an alt-click to go to the parent commit?

    Sometimes we want to view the version of a file before all of the commits in this PR.

    I think this would make sense as its own button. Also it would need to handle files created with this pr.

  3. OliverJAsh commented on Jun 26, 2020

    @OliverJAsh
    Author

    @yakov116 That would work, although it's less discoverable.

  4. fregante commented on Jun 26, 2020

    @fregante
    Member

    I find the lack of this really annoying. Is it possible that there’s no path to that page? I think it’s at least 3 clicks/pages away, which isn’t good.

    Suggestions welcome. Alt-click isn’t ideal in this case.

  5. OliverJAsh commented on Jun 26, 2020

    @OliverJAsh
    Author

    Is it possible that there’s no path to that page?

    Isn't it just as simple as replacing the commit param in the URL with the following?

    • For commits, ${COMMIT}^
    • For PRs, the name of the base branch
  6. fregante commented on Jun 26, 2020

    @fregante
    Member

    My question was: how is it possible that GitHub didn’t add this feature? Is there any other non-obvious way to reach that page?

    I’m not talking about “how to fix it,” because as you said it’s pretty easy.

  7. yakov116 commented on Jun 28, 2020

    @yakov116
    Member

    How about this?

    image

  8. yakov116 commented on Jun 29, 2020

    @yakov116
    Member

    @OliverJAsh Where do you expect to see the commit on the base branch or the head branch?

  9. OliverJAsh commented on Jun 29, 2020

    @OliverJAsh
    Author

    On the base branch/commit I think? (The existing "view file" points to the head branch/commit.)

  10. fregante commented on Aug 8, 2020

    @fregante
    Member

    This is possible:

    Made by:

    1. Wrap the existing .dropdown-item link into .d-flex
    2. Add identical link but use icon instead of text
    3. width: min-content; padding-left: 8px
    <div class="d-flex">
      {previousLink}
      <a {… previousLink attrs} style="padding-left: 8px !important;width: min-content;">
        <GitHistoryIcon/>
      </a>
    </div>

    This should be applied to regular commits as well.

    If a file is deleted by the current commit, the "View file" already points to the old commit, so in that case perhaps we should add the icon inside the existing link; this would indicate that the link points to the old commit.

  11. added
    small
    on Aug 5, 2022
  12. Vyvy-vi commented on Oct 29, 2022

    @Vyvy-vi
  13. fregante commented on Oct 29, 2022

    @fregante
  14. fregante commented on Jun 12, 2024

    @fregante
    Member

    Not one-click, but this is possible via the View History link added by more-file-links

  15. aslafy-z commented on Jan 10, 2025

    @aslafy-z

    This is still highly desirable! I see me View file, change branch to main, and update the org in the url too often!
    The design you @fregante made at #3289 (comment) would work verry well for me!
    Can you please re-open this issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    acceptedenhancementsmall

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions