Skip to main content
RapidDev - Software Development Agency
github-for-non-tech

How to View Previous Versions of a File on GitHub

To view an older version of a file on GitHub, navigate to the file and click the 'History' button to see all commits that touched it. Click any commit in the list, then click 'Browse files' to see the entire repository at that point in time — including the file as it looked before the change. You can also click the commit hash and then the file to view its exact content at that snapshot.

What you'll learn

  • How to view the history of a specific file
  • How to browse a file at any previous point in time
  • How to copy or download the old version of a file
  • When to use file history vs. full project history
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner7 min read6 minutesGitHub.com (Free, Pro, Team, Enterprise) — all plansMarch 2026RapidDev Engineering Team
TL;DR

To view an older version of a file on GitHub, navigate to the file and click the 'History' button to see all commits that touched it. Click any commit in the list, then click 'Browse files' to see the entire repository at that point in time — including the file as it looked before the change. You can also click the commit hash and then the file to view its exact content at that snapshot.

Every Version of Every File Is Preserved on GitHub

GitHub never truly deletes anything. Every version of every file that was ever committed is preserved in the repository's history. If a file was changed 20 times, all 20 versions still exist — you just need to know how to find them. This is incredibly useful when something stops working after a change. You can go back and see exactly what the file looked like before the problem started. You can compare the current version to an older version to spot the difference. And if needed, you can copy the old content and paste it back. The process starts with the 'History' button on any file page. This shows a list of every commit that modified that file, filtered to just that one file. From there, you can click any commit to see the diff or browse the file as it existed at that moment. This is one of GitHub's most practical features for non-technical founders. If an AI tool like Lovable or Cursor changed something and the result is not what you wanted, the old version is always accessible.

Prerequisites

  • A free GitHub account at github.com
  • A repository with a file that has been modified at least once

Step-by-step guide

1

Navigate to the file you want to inspect

Go to your repository on GitHub and click through the folder structure to find the file you want to view in its older state. For example, if you want to see the previous version of your pricing page, navigate to something like 'src/pages/Pricing.tsx.' Click on the filename to view its current contents. You should see the file content displayed with line numbers.

Expected result: You see the current contents of the file displayed in your browser.

2

Click the History button to see all changes to this file

Near the top-right of the file view, you will see several buttons including a pencil (edit), a trash can (delete), and a clock icon or the word 'History.' Click the 'History' button. GitHub opens a filtered commit list showing only the commits that modified this specific file. Each entry shows the commit message, the author, and the date. This is a curated timeline of every change ever made to this one file.

Expected result: You see a list of commits filtered to show only those that changed the file you selected.

3

Click a commit to see what changed

Click on any commit message in the history list. GitHub shows you the diff for that commit — the green and red lines showing what was added and removed in that specific save. This tells you what changed at that point. If you want to see the file as it looked BEFORE this change, look at the red (removed) lines. If you want to see the file as it looked AFTER this change, look at the green (added) lines.

Expected result: You see the diff showing what changed in this file during that commit.

4

Browse the file at a specific point in time

To see the complete file as it existed at a specific commit (not just the diff), go back to the file history list. On the right side of each commit entry, click the angle bracket icon '<>' or the 'Browse files' button. This loads the entire repository as it was at that exact moment. Navigate to the same file in the file tree — you will see its full contents as they were at that point in time. This is like opening a time capsule.

Expected result: You see the complete file contents as they existed at the selected commit.

5

Copy or download the old version

Once you are viewing the old version of the file, you can copy its contents by clicking the 'Copy raw file' button (the clipboard icon) near the top of the file view. You can also click the 'Raw' button to see the plain text content, which you can then select and copy. If you need to restore this version, you can copy the content and paste it into a new edit of the current file — then create a pull request with the restored content. This is a safe, no-code way to revert a file.

Expected result: You have copied the old file content and can paste it into a new edit or save it locally.

Complete working example

file-version-workflow.md
1# Viewing Previous File Versions Quick Reference
2
3## Step-by-step path:
4Repository File History Pick commit Browse files View file
5
6## Example:
71. Go to: github.com/yourname/myapp
82. Click: src/pages/Pricing.tsx
93. Click: History button (top-right)
104. See commits:
11 - a1b2c3d "Update pricing to $25/mo" (Mar 28)
12 - e4f5g6h "Add annual toggle" (Mar 25)
13 - i7j8k9l "Create pricing page" (Mar 20)
145. Click '<>' on "Create pricing page" commit
156. Navigate to src/pages/Pricing.tsx
167. You now see the file as it was on Mar 20
17
18## To restore an old version:
191. Copy the old file content (Raw or Copy button)
202. Navigate to the current version of the file
213. Click the pencil icon to edit
224. Replace all content with the copied old version
235. Choose "Create new branch and start PR"
246. Submit the PR for review

Common mistakes when viewing Previous Versions of a File on GitHub

Why it's a problem: Trying to edit a file while browsing a historical version

How to avoid: You cannot edit files in a historical snapshot. Navigate back to the current version (click the branch dropdown and select 'main') before editing.

Why it's a problem: Confusing the diff view with the full file view

How to avoid: The diff only shows changed lines. To see the complete file at a specific point in time, use the '<>' Browse files button, then navigate to the file.

Why it's a problem: Not realizing that all file paths may have changed

How to avoid: If a file was moved or renamed in a later commit, its old path might be different. Check the file tree when browsing the historical snapshot.

Why it's a problem: Overwriting the current file with an outdated version without review

How to avoid: Always create a pull request when restoring an old version. This lets someone review the restoration before it goes live.

Best practices

  • Use the file-specific History button instead of the full project history when investigating changes to one file.
  • Bookmark important commits by copying the URL when viewing a historical version — the URL is permanent.
  • When restoring an old version, create a pull request instead of committing directly to main.
  • Compare old and new versions side-by-side by opening two browser tabs — one with the old version and one with the current.
  • If an AI tool like Lovable made unwanted changes, use file history to find the last good version and restore it.
  • Check file history before asking someone to rewrite something — the version you want might already exist in the history.

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I need to restore a previous version of a file called Pricing.tsx in my GitHub repository. The current version was changed by Lovable and I want to go back to how it looked last week. Walk me through the steps on the GitHub website.

Frequently asked questions

Can I view a deleted file's previous version?

Yes. If a file was deleted, it still exists in the commits before the deletion. Browse the project at an older commit (before the file was deleted) and the file will be there.

How do I restore an old version of a file without using the terminal?

Browse the file at the historical commit, click 'Copy raw file,' then navigate to the current version, click the pencil icon to edit, replace all content with what you copied, and create a pull request.

Does viewing old versions cost anything or use credits?

No. Browsing file history and viewing old versions is completely free on all GitHub plans. It does not use any AI tool credits either.

Can I view old versions of files from an AI tool like Lovable?

Yes. If your Lovable project is connected to GitHub, every change Lovable made is stored as a commit. You can view the file at any commit using the History button, including versions before and after each AI edit.

What if the file was renamed — can I still find the old version?

Yes, but you may need to browse the repository at an older commit where the file had its previous name. GitHub sometimes tracks renames in the history, but not always reliably.

Can RapidDev help restore a previous version of my project?

Yes. RapidDev can help you navigate your repository's history, identify the correct version to restore, and safely create a pull request to roll back unwanted changes — without any risk of losing work.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.