🕷️ Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 16 (from laksa099)

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
20 days ago
🤖
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.7 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://www.nobledesktop.com/learn/git/undo-changes
Last Crawled2026-03-27 06:28:56 (20 days ago)
First Indexed2020-02-20 05:53:06 (6 years ago)
HTTP Status Code200
Meta TitleFree Tutorial: Undo Changes in Git
Meta DescriptionSometimes you make a mistake and want to go back to a previous version. Here's how to rollback changes.
Meta Canonicalnull
Boilerpipe Text
Sometimes you make a mistake and want to go back to a previous version. Here's how to rollback changes. Undoing Local Changes That Have Not Been Committed If you have made changes that you don't like, and they have not been committed yet, do as follows: In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. Run Git status and you should see the affected file listed. Run the following command, replacing filename.html with your file path (which you could copy and paste from the Git status command): Git checkout filename.html That file has now been reverted to the way it was at the previous commit (before your changes). Undoing a Specific Commit (That Has Been Pushed) If you have one specific commit you want to undo, you can revert it as follows: In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. Run Git status and make sure you have a clean working tree. Each commit has a unique hash (which looks something like 2f5451f ). You need to find the hash for the commit you want to undo. Here are two places you can see the hash for commits: In the commit history on the GitHub or Bitbucket or website. In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command Git log—oneline Once you know the hash for the commit you want to undo, run the following command (replacing 2f5451f with your commit's hash): Git revert 2f5451f—no-edit NOTE: The —no-edit option prevents Git from asking you to enter in a commit message. If you don't add that option, you'll end up in the VIM text editor. To exit VIM, press : to enter command mode, then q for quit, and finally hit Return (Mac) or Enter (Windows). This will make a new commit that is the opposite of the existing commit, reverting the file(s) to their previous state as if it was never changed. If working with a remote repo, you can now push those changes: Git push Undoing Your Last Commit (That Has Not Been Pushed) If you made a mistake on your last commit and have not pushed yet, you can undo it. For example, maybe you added some files and made a commit, and then immediately realized you forgot something. You can undo the commit, and then make a new (correct) commit. This will keep your history cleaner. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. Run this command: Git reset—soft HEAD~ TIP: Add a number to the end to undo multiple commits. For example, to undo the last 2 commits (assuming both have not been pushed) run Git reset—soft HEAD~2 NOTE: Git reset—soft HEAD~ is the same as Git reset—soft HEAD^ which you may see in Git documentation. Your latest commit will now be undone. Your changes remain in place, and the files go back to being staged (e.g., with Git add) so you can make any additional changes or add any missing files. You can then make a new commit. Undoing Local Changes That Have Been Committed (But Not Pushed) If you have made local commits that you don't like, and they have not been pushed yet you can reset things back to a previous good commit. It will be as if the bad commits never happened. Here's how: In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. Run Git status and make sure you have a clean working tree. Each commit has a unique hash (which looks something like 2f5451f ). You need to find the hash for the last good commit (the one you want to revert back to). Here are two places you can see the hash for commits: In the commit history on the GitHub or Bitbucket or website. In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command Git log—oneline Once you know the hash for the last good commit (the one you want to revert back to), run the following command (replacing 2f5451f with your commit's hash): Git reset 2f5451f Git reset—hard 2f5451f NOTE: If you do Git reset the commits will be removed, but the changes will appear as uncommitted, giving you access to the code. This is the safest option, because maybe you wanted some of that code and you can now make changes and new commits that are good. Often though you'll want to undo the commits and through away the code, which is what Git reset—hard does. Grow Your Skills We offer a full suite of coding courses for students of all levels. Learn through real-world projects from expert instructors. Check out our coding bootcamps and courses now: NYC web development courses NYC Python courses NYC data science courses NYC web design courses
Markdown
![](data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==) Award-winning tech training online and NYC [hello@nobledesktop.com](mailto:hello@nobledesktop.com) [FAQ](https://www.nobledesktop.com/faq) [Cart](https://www.nobledesktop.com/cart/view) Sign In - [Coding]() - [Python](https://www.nobledesktop.com/topics/python-classes-nyc) - [AI](https://www.nobledesktop.com/topics/ai-classes) - [Web Development](https://www.nobledesktop.com/topics/web-development-courses-nyc) - [JavaScript](https://www.nobledesktop.com/topics/javascript-classes-nyc) - [FinTech](https://www.nobledesktop.com/topics/fintech-bootcamps-nyc) - [High School Coding](https://www.nobledesktop.com/topics/high-school-summer-programs) - [Web Certificates](https://www.nobledesktop.com/topics/web-development-certificates-nyc) - [React](https://www.nobledesktop.com/classes/react-bootcamp) - [All Coding Classes & Bootcamps](https://www.nobledesktop.com/topics/coding-classes-nyc) - [Design]() - [Graphic Design](https://www.nobledesktop.com/topics/graphic-design-courses) - [Web Design](https://www.nobledesktop.com/topics/web-design-classes) - [Photoshop](https://www.nobledesktop.com/topics/photoshop-classes-nyc) - [After Effects](https://www.nobledesktop.com/topics/after-effects-classes-nyc) - [Premiere Pro](https://www.nobledesktop.com/topics/premiere-pro-classes-nyc) - [InDesign](https://www.nobledesktop.com/topics/indesign-classes-nyc) - [Illustrator](https://www.nobledesktop.com/topics/illustrator-classes-nyc) - [Video Editing](https://www.nobledesktop.com/topics/video-editing-classes) - [UX Design](https://www.nobledesktop.com/topics/ux-design-classes-nyc) - [Motion Graphics](https://www.nobledesktop.com/topics/motion-graphics-classes) - [Creative Cloud](https://www.nobledesktop.com/topics/adobe-classes-nyc) - [Figma](https://www.nobledesktop.com/topics/figma-classes-nyc) - [Revit](https://www.nobledesktop.com/topics/revit-classes) - [AutoCAD](https://www.nobledesktop.com/topics/autocad-courses-nyc) - [UI Design](https://www.nobledesktop.com/topics/visual-design-classes) - [Interior Design](https://www.nobledesktop.com/classes/intro-to-interior-design-online) - [All Design Classes & Certificates](https://www.nobledesktop.com/topics/design-courses) - [Business]() - [Digital Marketing](https://www.nobledesktop.com/topics/digital-marketing-courses) - [SEO](https://www.nobledesktop.com/topics/seo-training-nyc) - [Google Analytics](https://www.nobledesktop.com/topics/google-analytics-training-nyc) - [Google Ads](https://www.nobledesktop.com/topics/google-ads-training-nyc) - [Social Media](https://www.nobledesktop.com/topics/social-media-marketing-training-nyc) - [Data Analytics](https://www.nobledesktop.com/topics/data-analytics-training) - [Generative AI](https://www.nobledesktop.com/topics/ai-classes) - [PowerPoint](https://www.nobledesktop.com/topics/powerpoint) - [Microsoft Office](https://www.nobledesktop.com/topics/microsoft-office-classes) - [Finance](https://www.nobledesktop.com/topics/finance-classes-nyc) - [Project Management](https://www.nobledesktop.com/topics/project-management-courses-nyc) - [All Business Classes & Certificates](https://www.nobledesktop.com/topics/business-training) - [Data]() - [Data Analytics](https://www.nobledesktop.com/topics/data-analytics-training) - [SQL](https://www.nobledesktop.com/topics/sql-courses) - [Machine Learning](https://www.nobledesktop.com/topics/machine-learning-training-nyc) - [Tableau](https://www.nobledesktop.com/topics/tableau-training-nyc) - [Excel](https://www.nobledesktop.com/topics/excel-courses) - [Power BI](https://www.nobledesktop.com/classes/power-bi-bootcamp) - [Data Science](https://www.nobledesktop.com/topics/data-science-training) - [Python](https://www.nobledesktop.com/topics/python-classes-nyc) - [Certificates]() - [Graphic Design](https://www.nobledesktop.com/certificates/graphic-design) - [Data Science & AI](https://www.nobledesktop.com/certificates/data-science) - [Data Analytics](https://www.nobledesktop.com/certificates/data-analytics) - [Video Editing](https://www.nobledesktop.com/certificates/video-editing) - [UX & UI Design](https://www.nobledesktop.com/classes/ux-ui-design-program) - [Data Analytics & AI](https://www.nobledesktop.com/certificates/data-analytics-ai) - [Motion Graphics](https://www.nobledesktop.com/certificates/motion-graphics) - [Digital Marketing](https://www.nobledesktop.com/certificates/digital-marketing-bootcamp) - [Social Media](https://www.nobledesktop.com/certificates/social-media-marketing) - [UI Design](https://www.nobledesktop.com/certificates/visual-design) - [Digital Design](https://www.nobledesktop.com/certificates/digital-design) - [Full-Stack Web](https://www.nobledesktop.com/certificates/full-stack-development) - [Software Engineering](https://www.nobledesktop.com/certificates/software-engineering-bootcamp) - [Front-End Web](https://www.nobledesktop.com/certificates/front-end-web-development) - [JavaScript Development](https://www.nobledesktop.com/certificates/javascript-development) - [Python Developer](https://www.nobledesktop.com/certificates/python-developer) - [Video & Motion](https://www.nobledesktop.com/certificates/video-editing-motion-graphics-certificate) - [“MBA” Business](https://www.nobledesktop.com/certificates/mba-business) - [FinTech](https://www.nobledesktop.com/certificates/fintech-bootcamp-nyc) - [Web Design](https://www.nobledesktop.com/certificates/web-design) - [Generative AI](https://www.nobledesktop.com/certificates/generative-ai) - [IT Certifications](https://www.nobledesktop.com/topics/certifications) - [Find & Compare Certificates by Topic](https://www.nobledesktop.com/topics/technology-certificates-nyc) - Search: / - [Corporate](https://www.nobledesktop.com/corporate-training) - [Veterans](https://www.nobledesktop.com/veterans) - [Why Noble?](https://www.nobledesktop.com/benefits) - [Catalog](https://www.nobledesktop.com/courses) [FAQ](https://www.nobledesktop.com/faq) [Cart](https://www.nobledesktop.com/cart/view) Sign In - Coding - [Python](https://www.nobledesktop.com/topics/python-classes-nyc) - [AI](https://www.nobledesktop.com/topics/ai-classes) - [Web Development](https://www.nobledesktop.com/topics/web-development-courses-nyc) - [JavaScript](https://www.nobledesktop.com/topics/javascript-classes-nyc) - [FinTech](https://www.nobledesktop.com/topics/fintech-bootcamps-nyc) - [High School Coding](https://www.nobledesktop.com/topics/high-school-summer-programs) - [Web Certificates](https://www.nobledesktop.com/topics/web-development-certificates-nyc) - [React](https://www.nobledesktop.com/classes/react-bootcamp) - [All Coding Classes & Bootcamps](https://www.nobledesktop.com/topics/coding-classes-nyc) - Design - [Graphic Design](https://www.nobledesktop.com/topics/graphic-design-courses) - [Web Design](https://www.nobledesktop.com/topics/web-design-classes) - [Photoshop](https://www.nobledesktop.com/topics/photoshop-classes-nyc) - [After Effects](https://www.nobledesktop.com/topics/after-effects-classes-nyc) - [Premiere Pro](https://www.nobledesktop.com/topics/premiere-pro-classes-nyc) - [InDesign](https://www.nobledesktop.com/topics/indesign-classes-nyc) - [Illustrator](https://www.nobledesktop.com/topics/illustrator-classes-nyc) - [Video Editing](https://www.nobledesktop.com/topics/video-editing-classes) - [UX Design](https://www.nobledesktop.com/topics/ux-design-classes-nyc) - [Motion Graphics](https://www.nobledesktop.com/topics/motion-graphics-classes) - [Creative Cloud](https://www.nobledesktop.com/topics/adobe-classes-nyc) - [Figma](https://www.nobledesktop.com/topics/figma-classes-nyc) - [Revit](https://www.nobledesktop.com/topics/revit-classes) - [AutoCAD](https://www.nobledesktop.com/topics/autocad-courses-nyc) - [UI Design](https://www.nobledesktop.com/topics/visual-design-classes) - [Interior Design](https://www.nobledesktop.com/classes/intro-to-interior-design-online) - [All Design Classes & Certificates](https://www.nobledesktop.com/topics/design-courses) - Business - [Digital Marketing](https://www.nobledesktop.com/topics/digital-marketing-courses) - [SEO](https://www.nobledesktop.com/topics/seo-training-nyc) - [Google Analytics](https://www.nobledesktop.com/topics/google-analytics-training-nyc) - [Google Ads](https://www.nobledesktop.com/topics/google-ads-training-nyc) - [Social Media](https://www.nobledesktop.com/topics/social-media-marketing-training-nyc) - [Data Analytics](https://www.nobledesktop.com/topics/data-analytics-training) - [Generative AI](https://www.nobledesktop.com/topics/ai-classes) - [PowerPoint](https://www.nobledesktop.com/topics/powerpoint) - [Microsoft Office](https://www.nobledesktop.com/topics/microsoft-office-classes) - [Finance](https://www.nobledesktop.com/topics/finance-classes-nyc) - [Project Management](https://www.nobledesktop.com/topics/project-management-courses-nyc) - [All Business Classes & Certificates](https://www.nobledesktop.com/topics/business-training) - Data - [Data Analytics](https://www.nobledesktop.com/topics/data-analytics-training) - [SQL](https://www.nobledesktop.com/topics/sql-courses) - [Machine Learning](https://www.nobledesktop.com/topics/machine-learning-training-nyc) - [Tableau](https://www.nobledesktop.com/topics/tableau-training-nyc) - [Excel](https://www.nobledesktop.com/topics/excel-courses) - [Power BI](https://www.nobledesktop.com/classes/power-bi-bootcamp) - [Data Science](https://www.nobledesktop.com/topics/data-science-training) - [Python](https://www.nobledesktop.com/topics/python-classes-nyc) - Certificates - [Graphic Design](https://www.nobledesktop.com/certificates/graphic-design) - [Data Science & AI](https://www.nobledesktop.com/certificates/data-science) - [Data Analytics](https://www.nobledesktop.com/certificates/data-analytics) - [Video Editing](https://www.nobledesktop.com/certificates/video-editing) - [UX & UI Design](https://www.nobledesktop.com/classes/ux-ui-design-program) - [Data Analytics & AI](https://www.nobledesktop.com/certificates/data-analytics-ai) - [Motion Graphics](https://www.nobledesktop.com/certificates/motion-graphics) - [Digital Marketing](https://www.nobledesktop.com/certificates/digital-marketing-bootcamp) - [Social Media](https://www.nobledesktop.com/certificates/social-media-marketing) - [UI Design](https://www.nobledesktop.com/certificates/visual-design) - [Digital Design](https://www.nobledesktop.com/certificates/digital-design) - [Full-Stack Web](https://www.nobledesktop.com/certificates/full-stack-development) - [Software Engineering](https://www.nobledesktop.com/certificates/software-engineering-bootcamp) - [Front-End Web](https://www.nobledesktop.com/certificates/front-end-web-development) - [JavaScript Development](https://www.nobledesktop.com/certificates/javascript-development) - [Python Developer](https://www.nobledesktop.com/certificates/python-developer) - [Video & Motion](https://www.nobledesktop.com/certificates/video-editing-motion-graphics-certificate) - [“MBA” Business](https://www.nobledesktop.com/certificates/mba-business) - [FinTech](https://www.nobledesktop.com/certificates/fintech-bootcamp-nyc) - [Web Design](https://www.nobledesktop.com/certificates/web-design) - [Generative AI](https://www.nobledesktop.com/certificates/generative-ai) - [IT Certifications](https://www.nobledesktop.com/topics/certifications) - [Find & Compare Certificates by Topic](https://www.nobledesktop.com/topics/technology-certificates-nyc) More - [Corporate](https://www.nobledesktop.com/corporate-training) - [Veterans](https://www.nobledesktop.com/veterans) - [Why Noble?](https://www.nobledesktop.com/benefits) - [Catalog](https://www.nobledesktop.com/courses) - [Reviews](https://www.nobledesktop.com/testimonials) - [Awards & Accolades](https://www.nobledesktop.com/awards) - [Instructors](https://www.nobledesktop.com/instructors) - [Compare Courses](https://www.nobledesktop.com/compare) - [About Us](https://www.nobledesktop.com/about) - [Blog](https://www.nobledesktop.com/blog) - [Resources](https://www.nobledesktop.com/learn) # Undo Changes in Git: git checkout, git revert, & git reset Git Tips & Commands 1. [Learn Hub](https://www.nobledesktop.com/learn) 2. [Learn Git](https://www.nobledesktop.com/learn/git) 3. Undo Changes in Git: git checkout, git revert, & git reset ## Contents 1. [Undoing Local Changes That Have Not Been Committed](https://www.nobledesktop.com/learn/git/undo-changes#undoing-local-changes-that-have-not-been-committed) 2. [Undoing a Specific Commit (That Has Been Pushed)](https://www.nobledesktop.com/learn/git/undo-changes#undoing-a-specific-commit-that-has-been-pushed) 3. [Undoing Your Last Commit (That Has Not Been Pushed)](https://www.nobledesktop.com/learn/git/undo-changes#undoing-your-last-commit-that-has-not-been-pushed) 4. [Undoing Local Changes That Have Been Committed (But Not Pushed)](https://www.nobledesktop.com/learn/git/undo-changes#undoing-local-changes-that-have-been-committed-but-not-pushed) 5. [Grow Your Skills](https://www.nobledesktop.com/learn/git/undo-changes#grow-your-skills) June 5, 2025 Read more in [Git](https://www.nobledesktop.com/learn/git), [Front-End Web Development](https://www.nobledesktop.com/learn/front-end-web-development), [Web Development](https://www.nobledesktop.com/learn/web-development) Share Learn how to undo local changes, specific commits, and last commits in Git through this comprehensive guide. Master the commands and steps to navigate your Git repo and keep your projects clean and error-free. ## Key Insights - Uncommitted local changes in Git can be undone by navigating to the Git repo folder on your terminal, running git status to see the affected files, and running the command 'git checkout filename.html', which reverts the file to its state at the previous commit. - A specific commit that has been pushed can be undone by using the unique hash for the commit. The commit hash can be found in the commit history on GitHub, Bitbucket, or by running 'git log --oneline' on your terminal. The command 'git revert 2f5451f --no-edit' will create a new commit that reverses the existing commit. - The last commit that has not been pushed yet can be undone by running 'git reset --soft HEAD~' on your terminal. This command undoes the latest commit, keeps the changes in place, and reverts the files back to the staging area. - Local changes that have been committed but not yet pushed can be undone by running 'git reset 2f5451f' or 'git reset --hard 2f5451f' on your terminal. While the 'git reset' command removes the commits but keeps the changes as uncommitted, 'git reset --hard' undoes the commits and discards the changes. - Navigate the commands and steps to undo changes and commits in Git with real-world projects through comprehensive courses. These courses are offered by Noble Desktop and are taught by expert instructors. - Opportunities for further learning and skill development are available through a variety of courses and bootcamps offered in areas such as web development, Python, data science, and web design. Sometimes you make a mistake and want to go back to a previous version. Here's how to rollback changes. ## Undoing Local Changes That Have Not Been Committed If you have made changes that you don't like, and they **have not been committed** yet, do as follows: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your [Git](https://www.nobledesktop.com/learn/git/what-is-git) repo. 2. Run **Git status** and you should see the affected file listed. 3. Run the following command, replacing **filename.html** with your file path (which you could copy and paste from the Git status command): - **Git checkout filename.html** 4. That file has now been reverted to the way it was at the previous commit (before your changes). ## Undoing a Specific Commit (That Has Been Pushed) If you have one specific commit you want to undo, you can revert it as follows: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run **Git status** and make sure you have a clean working tree. 3. Each commit has a unique hash (which looks something like **2f5451f**). You need to find the hash for the commit you want to undo. Here are two places you can see the hash for commits: - In the commit history on the GitHub or Bitbucket or website. - In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command **Git log—oneline** 4. Once you know the hash for the commit you want to undo, run the following command (replacing **2f5451f** with your commit's hash): - **Git revert 2f5451f—no-edit** - **NOTE:** The **—no-edit** option prevents Git from asking you to enter in a commit message. If you don't add that option, you'll end up in the VIM text editor. To exit VIM, press **:** to enter command mode, then **q** for quit, and finally hit **Return** (Mac) or **Enter** (Windows). 5. This will make a new commit that is the opposite of the existing commit, reverting the file(s) to their previous state as if it was never changed. 6. If working with a remote repo, you can now push those changes: - **Git push** ## Undoing Your Last Commit (That Has Not Been Pushed) If you made a mistake on your last commit and have not pushed yet, you can undo it. For example, maybe you added some files and made a commit, and then immediately realized you forgot something. You can undo the commit, and then make a new (correct) commit. This will keep your history cleaner. [![Full-Stack Web Development Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjkxMjgsInB1ciI6ImJsb2JfaWQifX0=--d99d8316837bf5993fae4d7131695ea90bc6408b/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJ3ZWJwIiwicmVzaXplX3RvX2xpbWl0IjpbMTkyMCwxMDgwXSwicXVhbGl0eSI6ODV9LCJwdXIiOiJ2YXJpYXRpb24ifX0=--83586c15028ac46b3326789f6c2c05c27ea9a77c/full-stack-web.jpg)](https://www.nobledesktop.com/certificates/full-stack-development?utm_source=article_ad&utm_medium=learn-hub&utm_campaign=undo-changes) 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run this command: - **Git reset—soft HEAD~** - TIP: Add a number to the end to undo multiple commits. For example, to undo the last 2 commits (assuming both have not been pushed) run **Git reset—soft HEAD~2** - NOTE: **Git reset—soft HEAD~** is the same as **Git reset—soft HEAD^** which you may see in Git documentation. 3. Your latest commit will now be undone. Your changes remain in place, and the files go back to being staged (e.g., with Git add) so you can make any additional changes or add any missing files. You can then make a new commit. ## Undoing Local Changes That Have Been Committed (But Not Pushed) If you have made local commits that you don't like, and they **have not been pushed** yet you can reset things back to a previous good commit. It will be as if the bad commits never happened. Here's how: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run **Git status** and make sure you have a clean working tree. 3. Each commit has a unique hash (which looks something like **2f5451f**). You need to find the hash for the last good commit (the one you want to revert back to). Here are two places you can see the hash for commits: - In the commit history on the GitHub or Bitbucket or website. - In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command **Git log—oneline** 4. Once you know the hash for the last good commit (the one you want to revert back to), run the following command (replacing **2f5451f** with your commit's hash): - **Git reset 2f5451f** - **Git reset—hard 2f5451f** - **NOTE:** If you do **Git reset** the commits will be removed, but the changes will appear as uncommitted, giving you access to the code. This is the safest option, because maybe you wanted some of that code and you can now make changes and new commits that are good. Often though you'll want to undo the commits and through away the code, which is what **Git reset—hard** does. ## Grow Your Skills We offer a full suite of coding courses for students of all levels. Learn through real-world projects from expert instructors. Check out our coding bootcamps and courses now: - [NYC web development courses](https://www.nobledesktop.com/topics/web-development-courses-nyc) - [NYC Python courses](https://www.nobledesktop.com/topics/python-classes-nyc) - [NYC data science courses](https://www.nobledesktop.com/topics/data-science-training) - [NYC web design courses](https://www.nobledesktop.com/topics/web-design-classes) ### Learn more in these courses - ![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTE0MDUsInB1ciI6ImJsb2JfaWQifX0=--90ac0e4ccb13fadabc4e1279e3d2227f1cc3ace0/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemUiOiI3MDAiLCJxdWFsaXR5Ijo3MH0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--ca52cf0f4ba7ddf9b7c1dd61142e9790e1d841ae/python-for-data-science.png) Python for Data Science Bootcamp 30 hours \$1,495 [View course](https://www.nobledesktop.com/classes/python-data-science-bootcamp-nyc) - ![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTEzMTgsInB1ciI6ImJsb2JfaWQifX0=--e3c2beff6ed5ee6240e32804ff40745723d9da22/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemUiOiI3MDAiLCJxdWFsaXR5Ijo3MH0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--ca52cf0f4ba7ddf9b7c1dd61142e9790e1d841ae/front-end-cert.png) Front-End Web Development Certificate 108 hours \$3,495 [View course](https://www.nobledesktop.com/certificates/front-end-web-development) - ![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTEzNDAsInB1ciI6ImJsb2JfaWQifX0=--731c7efdb7a467dd9ae576a75aad2061030d9c08/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemUiOiI3MDAiLCJxdWFsaXR5Ijo3MH0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--ca52cf0f4ba7ddf9b7c1dd61142e9790e1d841ae/full-stack-cert.png) Full-Stack Web Development Certificate 420 hours \$7,995 [View course](https://www.nobledesktop.com/certificates/full-stack-development) - ![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MTEzNDUsInB1ciI6ImJsb2JfaWQifX0=--aeb42e4625088ca75a0bb92a4c133bf56fcfc95e/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJwbmciLCJyZXNpemUiOiI3MDAiLCJxdWFsaXR5Ijo3MH0sInB1ciI6InZhcmlhdGlvbiJ9fQ==--ca52cf0f4ba7ddf9b7c1dd61142e9790e1d841ae/software-engineering-cert.png) Software Engineering Certificate 510 hours \$10,995 [View course](https://www.nobledesktop.com/certificates/software-engineering-bootcamp) ### Related Resources - [Pull From a Remote Repository: git pull & git fetch](https://www.nobledesktop.com/learn/git/pull-fetch) - [Stage & Commit Files: git add, git commit, & git log](https://www.nobledesktop.com/learn/git/stage-commit-files) - [Ignore Files with .gitignore](https://www.nobledesktop.com/learn/git/ignore-files) ## How to Learn Git Master Git with hands-on training. Git is a free, open-source version control system that allows developers to track the changes they make to code. - [Full-Stack Web Development Certificate at Noble Desktop](https://www.nobledesktop.com/certificates/full-stack-development): live, instructor-led course available in NYC or live online - [Find Web Development Classes Near You](https://www.nobledesktop.com/web-development-classes): Search & compare dozens of available courses in-person - Explore [online Web Development classes](https://www.nobledesktop.com/topics/web-development-classes-online) - Train your staff with [corporate and onsite web development training](https://www.nobledesktop.com/corporate-training/web-development) ## Related Resources [![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6NTM5NiwicHVyIjoiYmxvYl9pZCJ9fQ==--ebe7b28a1291f191fae9c6453214e39cef025fa7/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJ3ZWJwIiwicmVzaXplIjoiODAwIiwicXVhbGl0eSI6NjB9LCJwdXIiOiJ2YXJpYXRpb24ifX0=--f3dbba17abee8cb6d78800a76c3a3dc5dcde53b7/Screen_Shot_2020-01-17_at_1.57.57_PM.png) Pull From a Remote Repository: git pull & git fetch After someone else makes changes to a remote repo, you can download (pull) their changes into your local repo.](https://www.nobledesktop.com/learn/git/pull-fetch) [![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6NTM5MywicHVyIjoiYmxvYl9pZCJ9fQ==--4cb8938e84598de879fedd5503c3124a591b03f1/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJ3ZWJwIiwicmVzaXplIjoiODAwIiwicXVhbGl0eSI6NjB9LCJwdXIiOiJ2YXJpYXRpb24ifX0=--f3dbba17abee8cb6d78800a76c3a3dc5dcde53b7/Screen_Shot_2020-01-15_at_1.15.56_PM.png) Stage & Commit Files: git add, git commit, & git log Think of Git as keeping a list of changes to files. So how do we tell Git to record our changes? Each recorded change to a file (or set of files) is called a commit. Read to learn more.](https://www.nobledesktop.com/learn/git/stage-commit-files) [![](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6NTM5NCwicHVyIjoiYmxvYl9pZCJ9fQ==--0cd396a868aed728b82f081d9ba7dfae3d4ed0dd/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJ3ZWJwIiwicmVzaXplIjoiODAwIiwicXVhbGl0eSI6NjB9LCJwdXIiOiJ2YXJpYXRpb24ifX0=--f3dbba17abee8cb6d78800a76c3a3dc5dcde53b7/Screen_Shot_2020-01-15_at_1.38.11_PM.png) Ignore Files with .gitignore There will be some files that you don't want Git to track. You can use a.gitignore file to list the files and/or folders that Git should ignore.](https://www.nobledesktop.com/learn/git/ignore-files) ### Contact Us Office Hours: 9am–6pm, Mon–Fri [‪(212) 226-4149](tel:+1-212-226-4149) [hello@nobledesktop.com](mailto:hello@nobledesktop.com) ### Location #### In-Person in NYC 185 Madison Avenue 3rd Floor New York, NY 10016 [Campus Info](https://www.nobledesktop.com/campus#in-person) #### Live Online from Anywhere [Live Online Info](https://www.nobledesktop.com/campus#live-online) Noble Desktop is today’s primary center for learning and career development. Since 1990, our project-based classes and certificate programs have given professionals the tools to pursue creative careers in design, coding, and beyond. Noble Desktop is licensed by the New York State Education Department. [![Best Coding Bootcamps in NYC](https://www.nobledesktop.com/assets/forbes-b01e51474d8a7cd6a808a8570c3fcf1ba759f290b6a59ebdb69e126f21a3d13f.svg)](https://www.forbes.com/advisor/bootcamps/best-coding-bootcamps-in-new-york/?award=best-coding-bootcamps-in-nyc-award-2024-noble-desktop-full-stack-web-development-certificate) [![The 38 best classes in NYC](https://www.nobledesktop.com/assets/timeout-c8712e7689f20b84e1144616587480768089ff56f53171a6c33b276efd3132f9.svg)](https://www.timeout.com/newyork/things-to-do/classes) ### Win a Free Class\! Enter your email to get tips, free giveaways, and more in our weekly newsletter. © 1998–2026 Noble Desktop - [Privacy & Terms](https://www.nobledesktop.com/privacy) ## Sign In or Register Or proceed with standard sign-in I have an account I’m a new customer
Readable Markdown
Sometimes you make a mistake and want to go back to a previous version. Here's how to rollback changes. ## Undoing Local Changes That Have Not Been Committed If you have made changes that you don't like, and they **have not been committed** yet, do as follows: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your [Git](https://www.nobledesktop.com/learn/git/what-is-git) repo. 2. Run **Git status** and you should see the affected file listed. 3. Run the following command, replacing **filename.html** with your file path (which you could copy and paste from the Git status command): - **Git checkout filename.html** 4. That file has now been reverted to the way it was at the previous commit (before your changes). ## Undoing a Specific Commit (That Has Been Pushed) If you have one specific commit you want to undo, you can revert it as follows: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run **Git status** and make sure you have a clean working tree. 3. Each commit has a unique hash (which looks something like **2f5451f**). You need to find the hash for the commit you want to undo. Here are two places you can see the hash for commits: - In the commit history on the GitHub or Bitbucket or website. - In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command **Git log—oneline** 4. Once you know the hash for the commit you want to undo, run the following command (replacing **2f5451f** with your commit's hash): - **Git revert 2f5451f—no-edit** - **NOTE:** The **—no-edit** option prevents Git from asking you to enter in a commit message. If you don't add that option, you'll end up in the VIM text editor. To exit VIM, press **:** to enter command mode, then **q** for quit, and finally hit **Return** (Mac) or **Enter** (Windows). 5. This will make a new commit that is the opposite of the existing commit, reverting the file(s) to their previous state as if it was never changed. 6. If working with a remote repo, you can now push those changes: - **Git push** ## Undoing Your Last Commit (That Has Not Been Pushed) If you made a mistake on your last commit and have not pushed yet, you can undo it. For example, maybe you added some files and made a commit, and then immediately realized you forgot something. You can undo the commit, and then make a new (correct) commit. This will keep your history cleaner. [![Full-Stack Web Development Certificate: Live & Hands-on, In NYC or Online, 0% Financing, 1-on-1 Mentoring, Free Retake, Job Prep. Named a Top Bootcamp by Forbes, Fortune, & Time Out. Noble Desktop. Learn More.](https://www.nobledesktop.com/rails/active_storage/representations/redirect/eyJfcmFpbHMiOnsiZGF0YSI6MjkxMjgsInB1ciI6ImJsb2JfaWQifX0=--d99d8316837bf5993fae4d7131695ea90bc6408b/eyJfcmFpbHMiOnsiZGF0YSI6eyJmb3JtYXQiOiJ3ZWJwIiwicmVzaXplX3RvX2xpbWl0IjpbMTkyMCwxMDgwXSwicXVhbGl0eSI6ODV9LCJwdXIiOiJ2YXJpYXRpb24ifX0=--83586c15028ac46b3326789f6c2c05c27ea9a77c/full-stack-web.jpg)](https://www.nobledesktop.com/certificates/full-stack-development?utm_source=article_ad&utm_medium=learn-hub&utm_campaign=undo-changes) 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run this command: - **Git reset—soft HEAD~** - TIP: Add a number to the end to undo multiple commits. For example, to undo the last 2 commits (assuming both have not been pushed) run **Git reset—soft HEAD~2** - NOTE: **Git reset—soft HEAD~** is the same as **Git reset—soft HEAD^** which you may see in Git documentation. 3. Your latest commit will now be undone. Your changes remain in place, and the files go back to being staged (e.g., with Git add) so you can make any additional changes or add any missing files. You can then make a new commit. ## Undoing Local Changes That Have Been Committed (But Not Pushed) If you have made local commits that you don't like, and they **have not been pushed** yet you can reset things back to a previous good commit. It will be as if the bad commits never happened. Here's how: 1. In your terminal (Terminal, Git Bash, or Windows Command Prompt), navigate to the folder for your Git repo. 2. Run **Git status** and make sure you have a clean working tree. 3. Each commit has a unique hash (which looks something like **2f5451f**). You need to find the hash for the last good commit (the one you want to revert back to). Here are two places you can see the hash for commits: - In the commit history on the GitHub or Bitbucket or website. - In your terminal (Terminal, Git Bash, or Windows Command Prompt) run the command **Git log—oneline** 4. Once you know the hash for the last good commit (the one you want to revert back to), run the following command (replacing **2f5451f** with your commit's hash): - **Git reset 2f5451f** - **Git reset—hard 2f5451f** - **NOTE:** If you do **Git reset** the commits will be removed, but the changes will appear as uncommitted, giving you access to the code. This is the safest option, because maybe you wanted some of that code and you can now make changes and new commits that are good. Often though you'll want to undo the commits and through away the code, which is what **Git reset—hard** does. ## Grow Your Skills We offer a full suite of coding courses for students of all levels. Learn through real-world projects from expert instructors. Check out our coding bootcamps and courses now: - [NYC web development courses](https://www.nobledesktop.com/topics/web-development-courses-nyc) - [NYC Python courses](https://www.nobledesktop.com/topics/python-classes-nyc) - [NYC data science courses](https://www.nobledesktop.com/topics/data-science-training) - [NYC web design courses](https://www.nobledesktop.com/topics/web-design-classes)
Shard16 (laksa)
Root Hash3123763098741622816
Unparsed URLcom,nobledesktop!www,/learn/git/undo-changes s443