🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 169 (from laksa196)

2. Crawled Status Check

Query:
Response:

3. Robots.txt Check

Query:
Response:

4. Spam/Ban Check

Query:
Response:

5. Seen Status Check

ℹ️ Skipped - page is already crawled

đź“„
INDEXABLE
âś…
CRAWLED
1 day ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0 months ago
History dropPASSisNull(history_drop_reason)No drop reason
Spam/banPASSfh_dont_index != 1 AND ml_spam_score = 0ml_spam_score=0
CanonicalPASSmeta_canonical IS NULL OR = '' OR = src_unparsedNot set

Page Details

PropertyValue
URLhttps://builtin.com/articles/git-revert-a-file
Last Crawled2026-04-26 06:00:35 (1 day ago)
First Indexed2025-02-11 18:45:09 (1 year ago)
HTTP Status Code200
Content
Meta TitleGit Revert a File: A Guide | Built In
Meta DescriptionA file can be reverted in Git using the git checkout command with the commit ID and the path to file. Learn how with these steps.
Meta Canonicalnull
Boilerpipe Text
Once you start collaborating with other developers, it’s going to be important to know how to revert a single file to a certain commit in Git . Sometimes you’ll need to change files not related to your pull request in order to test the feature you’re working on.  Git Revert a File Steps Find the commit ID of the version of the file you want to revert to. Find the path to the file you want to revert from the working directory. In the terminal, change directories to the working directory. Type git checkout [commit ID] -- path/to/file and hit enter. Commit the change to the reverted file. However, manually changing each line of code in those files back to their original state and doing a new commit can lead to a messy commit history. Reverting the file is a much cleaner way of handling it. 4 Steps to Revert a File in Git 1. Find the Commit ID First, you need to go to the shared repository on GitHub and find the file that you want to revert. Once you navigate to the file, you should see this right above the file: On the right hand side, you can see a seven digit commit ID and a date. That is the commit ID for the most recent commit in which that file was modified. Either write this commit ID down, or copy it to your clipboard. More on Git Git Merge Theirs Explained 2. Find the File Path The next thing you need is the path to the file from the working directory. This part is easy because the path to the file is on the same GitHub screen where you found the commit ID for the file. Above, you can see the same screenshot from before, but this time I’ve underlined the file path. Notice, I only underlined part of the path. The first directory listed is the working directory name, and will be the directory you’re in when using this file path. Because of this, you only want the underlined portion. 3. Revert the File All that is left is to revert the file. Once you’ve opened a terminal and changed to the working directory, you use git checkout to revert the file. The format of the Git command will look like this: git checkout [commit ID] -- path/ to /file If I were going to revert the file in the screenshots above, that would look like this: 4. Commit the Change I know what you’re thinking, “Wait a minute, I thought the whole point was to not create a new commit?” Well, that’s half true. We didn’t want a new commit for the file we reverted. But once we revert the file, we need to commit that change. In this case, the change is a revert of a single file. This done with the standard commit command: git commit -m 'commit message' Then you can push that commit to the remote so that the version of your branch on GitHub matches your local version. A tutorial on how to revert a commit in Git. | Video: Software Engineer Tutorials More on Git Getting Started With Version Control Systems Git Revert a File Using Git Restore Before we wrap things up, let’s look at how to revert a single file to remove uncommitted local changes. This is where git restore comes in handy. git restore is a very useful command that can unstage a file, or even remove all changes that have been made locally since that last commit, thus restoring the file.  For example, let’s say you’ve made changes to multiple files and staged all these modified files with the command git add . Afterward, you realize that you didn’t want the file named Index.js to be part of this commit. You can unstage that file with the command: git restore --staged index.js Once the file is unstaged, you can fully restore it to the previous commit with the command: git restore index .js Find the commit ID of the version of the file you want to revert to. Find the path to the file you want to revert from the working directory. In the terminal, change directories to the working directory. Type git checkout [commit ID] -- path/to/file and hit enter. Commit the change to the reverted file. If you want to restore a file in Git, you can use the command git restore . This allows you to unstage a file or remove all changes locally. For example you can enter:  git restore --staged index.js To unstage the file index.js from your commit. If you’d like to fully restore the file to the previous commit, you can use: git restore index .js
Markdown
[![Built In Logo](https://static.builtin.com/dist/images/bi-header-logo.svg) ![Built In Logo](https://static.builtin.com/dist/images/bi-header-logo.svg)](https://builtin.com/) [In Jobs](https://builtin.com/jobs?search=) [View All Jobs](https://builtin.com/jobs) [For Employers](https://employers.builtin.com/?utm_medium=BIReferral&utm_source=foremployers) [Join](https://builtin.com/auth/signup?destination=%2Farticles%2Fgit-revert-a-file) [Log In](https://builtin.com/auth/login?destination=%2Farticles%2Fgit-revert-a-file) - [Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Remote](https://builtin.com/jobs/remote) - [Articles](https://builtin.com/tech-topics) - [Best Places To Work](https://builtin.com/awards/us/2026/best-places-to-work) - [Job Application Tracker](https://builtin.com/auth/login?destination=%2Fhome%23application-tracker-section) - [Software Engineering Perspectives](https://builtin.com/tag/software-engineering-perspectives "Software Engineering Perspectives") - [Expert Contributors](https://builtin.com/tag/expert-contributors "Expert Contributors") - [Software Engineering](https://builtin.com/tag/software-engineering "Software Engineering") - \+1 - [Git](https://builtin.com/tag/git "Git") - \+3 # How to Revert a File in Git A file can be reverted in Git using the git checkout command with the commit ID and the path to file. Learn how with these steps. ![Joseph Trettevik](https://cdn.builtin.com/cdn-cgi/image/f=auto,w=96,h=96,q=100/sites/www.builtin.com/files/2025-02/Joseph%20Trettevik.jpeg) Written by [Joseph Trettevik](https://builtin.com/authors/joseph-trettevik) Published on Feb. 11, 2025 ![Two developers reviewing code files](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=cover,w=320,h=200,q=80/sites/www.builtin.com/files/2025-02/revert-a-file-in-git.png) Image: Shutterstock / Built In ![Brand Studio Logo](https://static.builtin.com/dist/images/expert-badge.svg) Once you start collaborating with other developers, it’s going to be important to know how to revert a single file to a certain commit in [Git](https://builtin.com/software-engineering-perspectives/git). Sometimes you’ll need to change files not related to your pull request in order to test the feature you’re working on. ## Git Revert a File Steps 1. Find the commit ID of the version of the file you want to revert to. 2. Find the path to the file you want to revert from the working directory. 3. In the terminal, change directories to the working directory. 4. Type `git checkout [commit ID] -- path/to/file` and hit enter. 5. Commit the change to the reverted file. However, manually changing each line of code in those files back to their original state and doing a new commit can lead to a messy commit history. Reverting the file is a much cleaner way of handling it. ## 4 Steps to Revert a File in Git ### 1\. **Find the Commit ID** First, you need to go to the shared repository on GitHub and find the file that you want to revert. Once you navigate to the file, you should see this right above the file: ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcqpmRte_UX82UIulblkob2NLKHsj6CebeaPE3bg0PiJdPOneMiq_RTrv4z63bgQnGb614jXsU-OBEdIKoVh8x9ftCK9Zjm84Y0V_GN_bD5NUsGrvW2UPG9zlhlYr_bQmv5_VQRAQ?key=n39osm7CwMRfsdbLFYrI8xn6) On the right hand side, you can see a seven digit commit ID and a date. That is the commit ID for the most recent commit in which that file was modified. Either write this commit ID down, or copy it to your clipboard. More on Git[Git Merge Theirs Explained](https://builtin.com/articles/git-merge-theirs) ### **2\.** Find the File Path The next thing you need is the path to the file from the working directory. This part is easy because the path to the file is on the same GitHub screen where you found the commit ID for the file. ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXf9BLY7r_AhIlGlvN1_sAYXFLPtmEkYUodOZt9LphU6nyUp496XQmQkMDDHQPEiEBL7TXXw_AubTG12kpTduEkvlpQvhFqtlWVdotyV2Yy9aBmDsww0yBVWE2mpsk6fzHTrCIHXXg?key=n39osm7CwMRfsdbLFYrI8xn6) Above, you can see the same screenshot from before, but this time I’ve underlined the file path. Notice, I only underlined part of the path. The first directory listed is the working directory name, and will be the directory you’re in when using this file path. Because of this, you only want the underlined portion. ### **3\.** Revert the File All that is left is to revert the file. Once you’ve opened a terminal and changed to the working directory, you use `git checkout` to revert the file. The format of the Git command will look like this: ``` git checkout [commit ID] -- path/to/file ``` If I were going to revert the file in the screenshots above, that would look like this: ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXehI9qzNw2ltjNrxOliNIV79g59mwKnHJ-1GkcN5yRvMccVQsEvJyUtwqc1h8HjlrIFCzZiIB7f6TdX2Rip7cNWIphLA0SoWEdpT0XBabKToHezOWGDZos-jHiS0NeeSeENK7BP_Q?key=n39osm7CwMRfsdbLFYrI8xn6) ### **4\.** Commit the Change I know what you’re thinking, “Wait a minute, I thought the whole point was to not create a new commit?” Well, that’s half true. We didn’t want a new commit for the file we reverted. But once we revert the file, we need to commit that change. In this case, the change is a revert of a single file. This done with the standard commit command: ``` git commit -m 'commit message' ``` Then you can push that [commit to the remote](https://builtin.com/software-engineering-perspectives/git-remote-host-identification-has-changed) so that the version of your [branch on GitHub](https://builtin.com/articles/git-branch-rename) matches your local version. A tutorial on how to revert a commit in Git. \| Video: Software Engineer Tutorials More on Git[Getting Started With Version Control Systems](https://builtin.com/articles/version-control-systems) ## Git Revert a File Using Git Restore Before we wrap things up, let’s look at how to revert a single file to remove uncommitted local changes. This is where `git restore` comes in handy. `git restore` is a very useful command that can unstage a file, or even remove all changes that have been made locally since that last commit, thus restoring the file. For example, let’s say you’ve made changes to multiple files and staged all these modified files with the command `git add`. Afterward, you realize that you didn’t want the file named `Index.js` to be part of this commit. You can unstage that file with the command: ``` git restore --staged index.js ``` Once the file is unstaged, you can [fully restore](https://git-scm.com/docs/git-restore) it to the previous commit with the command: ``` git restore index.js ``` ## Frequently Asked Questions ### How do you revert a single file in Git? 1. Find the commit ID of the version of the file you want to revert to. 2. Find the path to the file you want to revert from the working directory. 3. In the terminal, change directories to the working directory. 4. Type `git checkout [commit ID] -- path/to/file` and hit enter. 5. Commit the change to the reverted file. ### How do you restore a file in Git? If you want to restore a file in Git, you can use the command `git restore`. This allows you to unstage a file or remove all changes locally. For example you can enter: ``` git restore --staged index.js ``` To unstage the file `index.js` from your commit. If you’d like to fully restore the file to the previous commit, you can use: ``` git restore index.js ``` ### Recent Software Engineering Perspectives Articles [![Don’t Let Your AI Assistant Make You Lazy](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/2026-04/vibe-coding-lazy.png) Don’t Let Your AI Assistant Make You Lazy](https://builtin.com/articles/dont-let-ai-tool-make-you-lazy) [![Tokenmaxxing Explained: Why AI Use Is Becoming a Workplace Status Symbol](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/2026-04/tokenmaxxing.jpg) Tokenmaxxing Explained: Why AI Use Is Becoming a Workplace Status Symbol](https://builtin.com/articles/ai-tokenmaxxing) [![89 Companies Hiring Developers](https://cdn.builtin.com/cdn-cgi/image/f=auto,fit=contain,w=120,h=70,q=80/sites/www.builtin.com/files/2024-05/companies%20hiring%20developers.png) 89 Companies Hiring Developers](https://builtin.com/articles/companies-hiring-developers) Explore Job Matches. Job Title or Keyword Clear search Location Fully Remote, Hybrid, On Site Fully Remote Hybrid On Site Clear Apply See Jobs - [Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Articles](https://builtin.com/tech-topics) - [Tracker](https://builtin.com/auth/login?destination=%2Fhome%23application-tracker-section) - More ![Built In](https://static.builtin.com/dist/images/midnight_9.svg) [Join](https://builtin.com/auth/signup?destination=%2Farticles%2Fgit-revert-a-file) [Log In](https://builtin.com/auth/login?destination=%2Farticles%2Fgit-revert-a-file) - [Tech Jobs](https://builtin.com/jobs) - [Companies](https://builtin.com/companies) - [Articles](https://builtin.com/tech-topics) - [Remote](https://builtin.com/jobs/remote) - [Best Places To Work](https://builtin.com/awards/us/2026/best-places-to-work) - [Tech Hubs](https://builtin.com/tech-hubs) [Post Job](https://employers.builtin.com/membership?utm_medium=BIReferral&utm_source=foremployers) [![BuiltIn](https://static.builtin.com/dist/images/builtin-logo.svg)](https://builtin.com/) ![United We Tech](https://static.builtin.com/dist/images/united-we-tech.svg) Built In is the online community for startups and tech companies. Find startup jobs, tech news and events. About [Our Story](https://builtin.com/our-story) [Careers](https://employers.builtin.com/careers/) [Our Staff Writers](https://builtin.com/our-staff) [Content Descriptions](https://builtin.com/content-descriptions) *** Get Involved [Recruit With Built In](https://employers.builtin.com/membership?utm_medium=BIReferral&utm_source=foremployers) [Become an Expert Contributor](https://builtin.com/expert-contributors) *** Resources [Customer Support](https://knowledgebase.builtin.com/s/) [Share Feedback](https://form.jotform.com/223044927257054) [Report a Bug](https://knowledgebase.builtin.com/s/contactsupport) [Tech Job Tools + Career Resources](https://builtin.com/articles/grow-your-career) [Browse Jobs](https://builtin.com/browse-jobs) [Tech A-Z](https://builtin.com/tech-dictionary) *** Tech Hubs [Our Sites](https://builtin.com/our-sites) *** [Learning Lab User Agreement](https://builtin.com/learning-lab-user-agreement) [Accessibility Statement](https://builtin.com/accessibility-statement) [Copyright Policy](https://builtin.com/copyright-policy) [Privacy Policy](https://builtin.com/privacy-policy) [Terms of Use](https://builtin.com/community-terms-of-use) [Your Privacy Choices/Cookie Settings](https://builtin.com/california-do-not-sell-my-information) [CA Notice of Collection](https://builtin.com/ca-notice-collection) © Built In 2026
Readable Markdown
Once you start collaborating with other developers, it’s going to be important to know how to revert a single file to a certain commit in [Git](https://builtin.com/software-engineering-perspectives/git). Sometimes you’ll need to change files not related to your pull request in order to test the feature you’re working on. ## Git Revert a File Steps 1. Find the commit ID of the version of the file you want to revert to. 2. Find the path to the file you want to revert from the working directory. 3. In the terminal, change directories to the working directory. 4. Type `git checkout [commit ID] -- path/to/file` and hit enter. 5. Commit the change to the reverted file. However, manually changing each line of code in those files back to their original state and doing a new commit can lead to a messy commit history. Reverting the file is a much cleaner way of handling it. ## 4 Steps to Revert a File in Git ### 1\. **Find the Commit ID** First, you need to go to the shared repository on GitHub and find the file that you want to revert. Once you navigate to the file, you should see this right above the file: ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXcqpmRte_UX82UIulblkob2NLKHsj6CebeaPE3bg0PiJdPOneMiq_RTrv4z63bgQnGb614jXsU-OBEdIKoVh8x9ftCK9Zjm84Y0V_GN_bD5NUsGrvW2UPG9zlhlYr_bQmv5_VQRAQ?key=n39osm7CwMRfsdbLFYrI8xn6) On the right hand side, you can see a seven digit commit ID and a date. That is the commit ID for the most recent commit in which that file was modified. Either write this commit ID down, or copy it to your clipboard. More on Git[Git Merge Theirs Explained](https://builtin.com/articles/git-merge-theirs) ### **2\.** Find the File Path The next thing you need is the path to the file from the working directory. This part is easy because the path to the file is on the same GitHub screen where you found the commit ID for the file. ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXf9BLY7r_AhIlGlvN1_sAYXFLPtmEkYUodOZt9LphU6nyUp496XQmQkMDDHQPEiEBL7TXXw_AubTG12kpTduEkvlpQvhFqtlWVdotyV2Yy9aBmDsww0yBVWE2mpsk6fzHTrCIHXXg?key=n39osm7CwMRfsdbLFYrI8xn6) Above, you can see the same screenshot from before, but this time I’ve underlined the file path. Notice, I only underlined part of the path. The first directory listed is the working directory name, and will be the directory you’re in when using this file path. Because of this, you only want the underlined portion. ### **3\.** Revert the File All that is left is to revert the file. Once you’ve opened a terminal and changed to the working directory, you use `git checkout` to revert the file. The format of the Git command will look like this: ``` git checkout [commit ID] -- path/to/file ``` If I were going to revert the file in the screenshots above, that would look like this: ![Alt Text](https://lh7-rt.googleusercontent.com/docsz/AD_4nXehI9qzNw2ltjNrxOliNIV79g59mwKnHJ-1GkcN5yRvMccVQsEvJyUtwqc1h8HjlrIFCzZiIB7f6TdX2Rip7cNWIphLA0SoWEdpT0XBabKToHezOWGDZos-jHiS0NeeSeENK7BP_Q?key=n39osm7CwMRfsdbLFYrI8xn6) ### **4\.** Commit the Change I know what you’re thinking, “Wait a minute, I thought the whole point was to not create a new commit?” Well, that’s half true. We didn’t want a new commit for the file we reverted. But once we revert the file, we need to commit that change. In this case, the change is a revert of a single file. This done with the standard commit command: ``` git commit -m 'commit message' ``` Then you can push that [commit to the remote](https://builtin.com/software-engineering-perspectives/git-remote-host-identification-has-changed) so that the version of your [branch on GitHub](https://builtin.com/articles/git-branch-rename) matches your local version. A tutorial on how to revert a commit in Git. \| Video: Software Engineer Tutorials More on Git[Getting Started With Version Control Systems](https://builtin.com/articles/version-control-systems) ## Git Revert a File Using Git Restore Before we wrap things up, let’s look at how to revert a single file to remove uncommitted local changes. This is where `git restore` comes in handy. `git restore` is a very useful command that can unstage a file, or even remove all changes that have been made locally since that last commit, thus restoring the file. For example, let’s say you’ve made changes to multiple files and staged all these modified files with the command `git add`. Afterward, you realize that you didn’t want the file named `Index.js` to be part of this commit. You can unstage that file with the command: ``` git restore --staged index.js ``` Once the file is unstaged, you can [fully restore](https://git-scm.com/docs/git-restore) it to the previous commit with the command: ``` git restore index.js ``` 1. Find the commit ID of the version of the file you want to revert to. 2. Find the path to the file you want to revert from the working directory. 3. In the terminal, change directories to the working directory. 4. Type `git checkout [commit ID] -- path/to/file` and hit enter. 5. Commit the change to the reverted file. If you want to restore a file in Git, you can use the command `git restore`. This allows you to unstage a file or remove all changes locally. For example you can enter: ``` git restore --staged index.js ``` To unstage the file `index.js` from your commit. If you’d like to fully restore the file to the previous commit, you can use: ``` git restore index.js ```
ML Classification
ML Categories
/Computers_and_Electronics
96.8%
/Computers_and_Electronics/Software
86.6%
/Computers_and_Electronics/Software/Software_Utilities
66.9%
/Internet_and_Telecom
13.0%
/Internet_and_Telecom/Web_Services
12.3%
/Internet_and_Telecom/Web_Services/Web_Design_and_Development
11.8%
Raw JSON
{
    "/Computers_and_Electronics": 968,
    "/Computers_and_Electronics/Software": 866,
    "/Computers_and_Electronics/Software/Software_Utilities": 669,
    "/Internet_and_Telecom": 130,
    "/Internet_and_Telecom/Web_Services": 123,
    "/Internet_and_Telecom/Web_Services/Web_Design_and_Development": 118
}
ML Page Types
/Article
99.8%
/Article/Tutorial_or_Guide
52.1%
Raw JSON
{
    "/Article": 998,
    "/Article/Tutorial_or_Guide": 521
}
ML Intent Types
Informational
99.5%
Raw JSON
{
    "Informational": 995
}
Content Metadata
Languageen
AuthorJoseph Trettevik
Publish Timenot set
Original Publish Time2025-02-11 18:45:09 (1 year ago)
RepublishedNo
Word Count (Total)1,069
Word Count (Content)788
Links
External Links9
Internal Links53
Technical SEO
Meta NofollowNo
Meta NoarchiveNo
JS RenderedYes
Redirect Targetnull
Performance
Download Time (ms)243
TTFB (ms)242
Download Size (bytes)13,570
Shard169 (laksa)
Root Hash7607033694470393769
Unparsed URLcom,builtin!/articles/git-revert-a-file s443