question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Add "view file before commit/PR"

See original GitHub issue

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.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:6
  • Comments:11 (7 by maintainers)

github_iconTop GitHub Comments

1reaction
fregantecommented, Aug 8, 2020

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.

1reaction
OliverJAshcommented, Jun 29, 2020

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Add "view file before commit/PR" · Issue #1826 · isaacs/github
For the longest time I have been doing this manually, by clicking "view file" and then editing the URL to add a ^...
Read more >
How to see changes to a file before commit? - Stack Overflow
You can stage changes manually with git add , or if the files are already versioned, you can use git commit -a -v...
Read more >
Making additional edits on a file after opening a PR
Steps: Viewing your PR in Github, click the “Files Changed” tab. Click the three dots in the top right corner of the editor...
Read more >
Add, edit, and commit to source files | Bitbucket Cloud
Edit files online · From the repository, click Source in the left navigation. · Click the file you want to open. · Click...
Read more >
How to Open a Pull Request - Gatsby
Once a pull request is opened, you can discuss and review the potential changes with collaborators and add follow-up commits before your changes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found