šŸ•·ļø Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 39 (from laksa168)

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
18 minutes 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://phoenixnap.com/kb/git-revert-last-commit
Last Crawled2026-04-11 14:32:33 (18 minutes ago)
First Indexed2020-03-19 16:48:18 (6 years ago)
HTTP Status Code200
Meta TitleGit Revert Commit: How to Revert Previous Commit
Meta DescriptionLearn how to revert your Git commits the easy way. This tutorial has all the commands you need with examples, git reset & git revert. Undo the last commit!
Meta Canonicalnull
Boilerpipe Text
Home Ā» KB Ā» SysAdmin Ā» Git Revert Commit: How to Undo Last Commit Topics: Git is a popular project tracking application. As a project progresses through different revisions, those revisions are published as aĀ  commit . A commit represents a checkpoint, where a copy of the project is saved at a specific point. This guide shows you how to undo the last commit in git. Prerequisites An existing project in Git Access to a terminal window/command line Note: If you wish to undo a commit to correct an error in the commit message, there is a better way to do it. Learn how to change a Git commit message . How to Revert Commit Git offers many features to manage your project from different historical commits. You can view and revert a previous commit, either published or unpublished. Read on to learn how to identify and revert a published commit. Also, if you want to learn more about Git, check out our article on how does Git work . Identifying the Commit AĀ hashĀ is an alphanumeric code that identifies each commit. Enter the following command to display a commit hash: git log The hash is necessary to display or manage a specific commit. To analyze the status of your project from a previous commit, use theĀ checkoutĀ command: git checkout [hash] When using a hash with a Git command, there is no need to type it in its entirety. The first few unique characters are enough for Git to identify an entry accurately. Note: Find out how to use Git checkout tags and why they are useful for your development project. Git Revert: Reverting the Last Git Commit Once a commit is uploaded to the server, it creates a more permanent project log. It is not advisable to useĀ  reset Ā in this case as other developers may have retrieved the updated project already. Deleting updates from one system may cause conflicts with other team members. Instead, use theĀ  revert Ā command: git revert [hash] Make sure to enter the code for the hash you want to revert to. The system asks you to enter a specific commit message for the changes theĀ  revert Ā command is going to perform. This action creates a new commit based on the one you specified, with aĀ  revert tag. This acts as a log, showing that the commit was published and then reverted (instead of pretending it never happened). Note: Learn how to use Git cherry-pick to select and apply a single commit from one branch to another. Git Reset: Revert Unpublished Commits An unpublished commit is an update committed in Git but that has not been uploaded to a server. To reset to a previous commit, before any changes were made: git reset --hard [hash] This command wipes the slate clean back to the previous commit. Any changes you made will be lost after using the reset --hard command . If you want to preserve your work, you can use Git stash : git stash git reset --hard [hash] git stash pop TheĀ  stash Ā  command saves the work you did, andĀ  stash pop retrieves those changes after the reset. Alternately you can use the following: git reset --soft [hash] This command resets the commit history, but it leaves your working directory and staging index as-is. Note: Git stash allows users to save their uncommitted files and work in progress to a local stash. Learn how to Git stash specific files . Git Amend: Modify the Last Commit To modify the most recent commit, use the git commit --amend command. This command replaces the last commit with the amended commit without altering the snapshot. The --amend flag is usually used to fix minor mistakes. For instance, you want to commit a couple of files in a single snapshot but forget to add one of the files before committing. This issue is easily solved using the --amend option. First, you add the missing file using: git add file2.py Then, run the command: git commit --amend --no-edit The --no-edit option amends the commit without changing the commit message. Conclusion You now know how to use the revert and reset commands to undo changes and revert to a previous commit. Additionally, you have learned how to check the status of your current commit. Remember not to use reset for published commits as it may lead to version conflicts. Was this article helpful? Yes No
Markdown
- [Call](https://phoenixnap.com/kb/git-revert-last-commit) - [Support](tel:1-855-330-1509) - [Sales](tel:1-877-588-5918) - [Login](https://phoenixnap.com/kb/git-revert-last-commit) - [Bare Metal Cloud](https://bmc.phoenixnap.com/) - [Admin Hub](https://admin.phoenixnap.com/) - [Partners](https://phoenixnap.com/partners) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-colocation-mobile.svg)COLOCATION](https://phoenixnap.com/colocation) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/02-colocation-plus.svg)Colocation Premier Carrier Hotel](https://phoenixnap.com/colocation) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/03-data-center-as-a-service.svg)Data Center as a Service Solutions for Digital Transformation](https://phoenixnap.com/colocation/data-center-as-a-service) - [Data Center as a Service Overview](https://phoenixnap.com/colocation/data-center-as-a-service) - [Hardware as a Service Flexible Hardware Leasing](https://phoenixnap.com/colocation/hardware-as-a-service) - [Bare Metal Cloud API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud) - [Object Storage S3 API Compatible Storage Service](https://phoenixnap.com/object-storage) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/04-meet-me-room.svg)Meet-Me Room The Interconnectivity Hub](https://phoenixnap.com/colocation/meet-me-room) - [Meet-Me Room Overview](https://phoenixnap.com/colocation/meet-me-room) - [AWS Direct Connect Dedicated Link to Amazon Cloud](https://phoenixnap.com/colocation/aws-direct-connect) - [Google Cloud Interconnect Private Connectivity to Google Cloud](https://phoenixnap.com/google-cloud-interconnect) - [Megaport Cloud Router Simplified Multi-Cloud Connections](https://phoenixnap.com/offers/megaport-cloud-router) - [All Carriers Global Interconnectivity Options](https://phoenixnap.com/colocation/all-carriers) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/05-schedule-a-tour.svg)Schedule a Tour Guided Virtual Data Center Tour](https://phoenixnap.com/phoenix-data-center-virtual-tour) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/06-data-center-locations.svg)Data Center Locations Global Data Center Footprint](https://phoenixnap.com/colocation/data-center-locations) - [Data Center Locations Overview](https://phoenixnap.com/colocation/data-center-locations) - [Phoenix, AZ The Largest Fiber Backbone in the U.S.](https://phoenixnap.com/colocation/phoenix) - [Amsterdam, NL The Connectivity Hub of Europe](https://phoenixnap.com/colocation/amsterdam) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-bare-metal-cloud-platform.svg)BARE METAL CLOUD](https://phoenixnap.com/bare-metal-cloud) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-bare-metal-cloud-platform.svg)Platform API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud) - [Platform Overview](https://phoenixnap.com/bare-metal-cloud) - [Infrastructure As Code DevOps Integrations](https://phoenixnap.com/bare-metal-cloud/infrastructure-as-code) - [BMC vs. Dedicated Servers Choose the Best Option](https://phoenixnap.com/bare-metal-cloud-vs-dedicated-servers) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/02-bare-metal-cloud-pricing.svg)Pricing Instance pricing and cost estimation](https://phoenixnap.com/kb/git-revert-last-commit) - [Instance Pricing See All Configurations](https://phoenixnap.com/bare-metal-cloud/instances) - [Pricing Calculator Get an Estimate](https://phoenixnap.com/cloud-pricing-calculator) - [Network/IP Pricing Flexible IP Pricing](https://phoenixnap.com/bare-metal-cloud/ip-pricing) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/03-kubernetes-solutions.svg)Kubernetes Solutions Streamlined Kubernetes Management](https://phoenixnap.com/kb/git-revert-last-commit) - [Rancher Deployment One-Click Kubernetes Deployment](https://phoenixnap.com/bare-metal-cloud/rancher-deployment) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/04-cpus.svg)CPUs Next Gen Intel Processors](https://phoenixnap.com/kb/git-revert-last-commit) - [Xeon 6 6700-series with E-Cores Supercharge Cloud-Native Workloads](https://phoenixnap.com/bare-metal-cloud/intel-xeon-6-processors-with-e-cores) - [IntelĀ® Coreā„¢ i9 14900K Ideal for Gaming, Streaming, and Content Creation](https://phoenixnap.com/bare-metal-cloud/intel-core-i9-14900k) - [5th Gen Intel Xeon Scalable CPUs Boost Data-Intensive Workloads](https://phoenixnap.com/bare-metal-cloud/5th-gen-intel-xeon-scalable-processors) - [HPE Ampere Altra Q80-30 HPEĀ® ProLiant RL300 as a service](https://phoenixnap.com/bare-metal-cloud/hpe-proliant-rl300) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/05-alliances.svg)Alliances Technology Partnerships](https://phoenixnap.com/bare-metal-cloud/technology-ecosystem) - [Ecosystem Underlying Technologies](https://phoenixnap.com/bare-metal-cloud/technology-ecosystem) - [NetrisOS VPC networking on bare metal](https://phoenixnap.com/bare-metal-cloud/netris) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/06-storage-options.svg)Storage Options Flexible Storage Solutions](https://phoenixnap.com/kb/git-revert-last-commit) - [Object Storage S3-Compatible Storage Solution](https://phoenixnap.com/object-storage) - [Network File Storage All-Flash Scale-Out Storage Resources](https://phoenixnap.com/network-file-storage) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/07-gpu-servers.svg)GPU Servers For AI/ML and HPC workloads](https://phoenixnap.com/kb/git-revert-last-commit) - [Intel Max 1100 GPUs 1 system. 2 GPUs. Amazing performance.](https://phoenixnap.com/bare-metal-cloud/gpu-servers) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-hybrid-cloud-mobile.svg)HYBRID CLOUD](https://phoenixnap.com/security/data-security-cloud) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/02-hybrid-cloud-overview.svg)Hybrid Cloud Overview](https://phoenixnap.com/cloud-services/hybrid-cloud-solutions) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/03-object-storage.svg)Object Storage S3 Compatible Storage Solution](https://phoenixnap.com/object-storage) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/04-bare-metal-cloud.svg)Bare Metal Cloud API-Driven Dedicated Servers](https://phoenixnap.com/bare-metal-cloud) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/05-alternative-cloud-provider.svg)Alternative Cloud Provider Overcome Public Cloud Limitations](https://phoenixnap.com/cloud-services/alternative-cloud-provider) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/06-backup-solutions.svg)Backup Solutions Veeam-Powered Services](https://phoenixnap.com/backup-restore) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/07-disaster-recovery.svg)Disaster Recovery VMware, Veeam, Zerto](https://phoenixnap.com/disaster-recovery-as-a-service-draas) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/08-veeam-cloud-connect.svg)Veeam Cloud Connect Backup and Replication](https://phoenixnap.com/backup-restore/veeam-cloud-connect) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/09-managed-backup-for-microsoft-365.svg)Managed Backup for Microsoft 365 Veeam-Powered Service](https://phoenixnap.com/backup-restore/microsoft-365-backup) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-network-mobile.svg)NETWORK](https://phoenixnap.com/network) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/02-network-overview.svg)Network Overview Global Network Footprint](https://phoenixnap.com/network) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/03-network-locations.svg)Network Locations U.S., Europe, APAC, LATAM](https://phoenixnap.com/network/locations) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/04-speed-test.svg)Speed Test Download Speed Test](https://phoenixnap.com/network/speed-test) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/01-learn-mobile.svg)LEARN](https://phoenixnap.com/kb) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/02-blog.svg)Blog IT Tips and Tricks](https://phoenixnap.com/blog/) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/04-resource-library.svg)Resource Library Knowledge Resources](https://phoenixnap.com/company/resource-library) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/05-glossary.svg)Glossary IT Terms and Definitions](https://phoenixnap.com/glossary/) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/06-events.svg)Events Let's Meet\!](https://phoenixnap.com/company/it-events) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/07-newsroom.svg)Newsroom Media Library](https://phoenixnap.com/company/press) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/08-developers.svg)Developers Development Resources Portal](https://developers.phoenixnap.com/) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/09-apis.svg)APIs Access Our Public APIs](https://developers.phoenixnap.com/apis) - [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%201%201'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2025/11/10-github.svg)GitHub Public Code Repositories](https://github.com/phoenixnap) [Home](https://phoenixnap.com/) Ā» [KB](https://phoenixnap.com/kb/) Ā» [SysAdmin](https://phoenixnap.com/kb/category/sysadmin) Ā» Git Revert Commit: How to Undo Last Commit # Git Revert Commit: How to Undo Last Commit ![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%200%200'%3E%3C/svg%3E) ![](https://secure.gravatar.com/avatar/8d4609e99e6aecc69ce049e18d45f033?s=200&d=mm&r=g) By [Vladimir Kaplarevic](https://phoenixnap.com/kb/author/vladimirk) Published: March 3, 2022 Topics: [git](https://phoenixnap.com/kb/tag/git) [Git](https://phoenixnap.com/kb/what-is-git) is a popular project tracking application. As a project progresses through different revisions, those revisions are published as a [commit](https://phoenixnap.com/kb/git-commit). A commit represents a checkpoint, where a copy of the project is saved at a specific point. **This guide shows you how to undo the last commit in git.** ![How can I revert the last commit in git?](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20801%20402'%3E%3C/svg%3E) ![How can I revert the last commit in git?](https://phoenixnap.com/kb/wp-content/uploads/2021/04/how-to-revert-the-last-commit-in-git.png) Prerequisites - An existing project in Git - Access to a terminal window/command line **Note:** If you wish to undo a commit to correct an error in the commit message, there is a better way to do it. Learn how to [change a Git commit message](https://phoenixnap.com/kb/git-change-commit-message). ## How to Revert Commit Git offers many features to manage your project from different historical commits. You can view and revert a previous commit, either published or unpublished. Read on to learn how to identify and revert a published commit. Also, if you want to learn more about Git, check out our article on [how does Git work](https://phoenixnap.com/kb/how-git-works). ### Identifying the Commit A hash is an alphanumeric code that identifies each commit. Enter the following command to display a commit hash: ``` git log ``` The hash is necessary to display or manage a specific commit. ![Example of Git commit hash](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20110'%3E%3C/svg%3E) ![Example of Git commit hash](https://phoenixnap.com/kb/wp-content/uploads/2021/04/find-git-commit-hash-log.png) To analyze the status of your project from a previous commit, use the checkout command: ``` git checkout [hash] ``` When using a hash with a Git command, there is no need to type it in its entirety. The first few unique characters are enough for Git to identify an entry accurately. **Note:** Find out how to use [Git checkout tags](https://phoenixnap.com/kb/git-checkout-tag) and why they are useful for your development project. ### Git Revert: Reverting the Last Git Commit Once a commit is uploaded to the server, it creates a more permanent project log. It is not advisable to use **reset** in this case as other developers may have retrieved the updated project already. Deleting updates from one system may cause conflicts with other team members. Instead, use the **revert** command: ``` git revert [hash] ``` Make sure to enter the code for the hash you want to revert to. The system asks you to enter a specific commit message for the changes the **revert** command is going to perform. ![Define commit message for the revert action](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20235'%3E%3C/svg%3E) ![Define commit message for the revert action](https://phoenixnap.com/kb/wp-content/uploads/2021/04/commit-message-for-git-revert-command.png) This action creates a new commit based on the one you specified, with a **`revert`** tag. This acts as a log, showing that the commit was published and then reverted (instead of pretending it never happened). **Note:** Learn how to use [Git cherry-pick](https://phoenixnap.com/kb/git-cherry-pick) to select and apply a single commit from one branch to another. ## Git Reset: Revert Unpublished Commits An **unpublished commit** is an update committed in Git but that has not been uploaded to a server. To reset to a previous commit, before any changes were made: ``` git reset --hard [hash] ``` This command wipes the slate clean back to the previous commit. Any changes you made will be lost after using the [reset --hard command](https://phoenixnap.com/kb/git-reset-hard). If you want to preserve your work, you can use [Git stash](https://phoenixnap.com/kb/git-stash): ``` git stash git reset --hard [hash] git stash pop ``` The **`stash`** command saves the work you did, and **`stash pop`** retrieves those changes after the reset. Alternately you can use the following: ``` git reset --soft [hash] ``` This command resets the commit history, but it leaves your working directory and staging index as-is. **Note:** Git stash allows users to save their uncommitted files and work in progress to a local stash. Learn how to [Git stash specific files](https://phoenixnap.com/kb/git-stash-specific-files). ## Git Amend: Modify the Last Commit To modify the most recent commit, use the **`git commit --amend`** command. This command replaces the last commit with the amended commit without altering the snapshot. The **`--amend`** flag is usually used to fix minor mistakes. For instance, you want to commit a couple of files in a single snapshot but forget to add one of the files before committing. This issue is easily solved using the **`--amend`** option. First, you add the missing file using: ``` git add file2.py ``` Then, run the command: ``` git commit --amend --no-edit ``` The **`--no-edit`** option amends the commit without changing the commit message. **Note:** If you need to restore a missing repository, refer to our guide [How to Restore a Git Repository](https://phoenixnap.com/kb/restore-git-repository). Conclusion You now know how to use the **`revert`** and **`reset`** commands to undo changes and revert to a previous commit. Additionally, you have learned how to check the status of your current commit. Remember not to use **`reset`** for published commits as it may lead to version conflicts. Was this article helpful? YesNo Contents - [How to Revert Commit](https://phoenixnap.com/kb/git-revert-last-commit#How_to_Revert_Commit) - [Identifying the Commit](https://phoenixnap.com/kb/git-revert-last-commit#Identifying_the_Commit) - [Git Revert: Reverting the Last Git Commit](https://phoenixnap.com/kb/git-revert-last-commit#Git_Revert_Reverting_the_Last_Git_Commit) - [Git Reset: Revert Unpublished Commits](https://phoenixnap.com/kb/git-revert-last-commit#Git_Reset_Revert_Unpublished_Commits) - [Git Amend: Modify the Last Commit](https://phoenixnap.com/kb/git-revert-last-commit#Git_Amend_Modify_the_Last_Commit) Subscribe to our newsletter [SUBSCRIBE](https://phoenixnap.com/developers-monthly-newsletter) Next you should read [![How to Undo & Redo in Vim/Vi](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20799%20400'%3E%3C/svg%3E)![How to Undo & Redo in Vim/Vi](https://phoenixnap.com/kb/wp-content/uploads/2024/10/how-to-undo-and-redo-in-vi-vim.png)](https://phoenixnap.com/kb/vim-undo-redo) [DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin) [How to Undo and Redo Changes in Vim / Vi](https://phoenixnap.com/kb/vim-undo-redo) [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20800%20400'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2023/09/how-to-switch-branch-in-git.png)](https://phoenixnap.com/kb/git-switch-branch) [DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin) [How To Switch Branch on Git](https://phoenixnap.com/kb/git-switch-branch) [![](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20799%20400'%3E%3C/svg%3E)![](https://phoenixnap.com/kb/wp-content/uploads/2021/04/how-to-install-git-on-centos8.png)](https://phoenixnap.com/kb/how-to-install-git-centos-8) [DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [Web Servers](https://phoenixnap.com/kb/category/web-servers) [How to Install Git on CentOS 8](https://phoenixnap.com/kb/how-to-install-git-centos-8) [![tutorial on renaming or changing the name of a local and remote branch in git](data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%20801%20402'%3E%3C/svg%3E)![tutorial on renaming or changing the name of a local and remote branch in git](https://phoenixnap.com/kb/wp-content/uploads/2021/04/how-to-rename-git-branch.png)](https://phoenixnap.com/kb/how-to-rename-git-branch-local-remote) [DevOps and Development](https://phoenixnap.com/kb/category/devops-and-development) [SysAdmin](https://phoenixnap.com/kb/category/sysadmin) [How To Rename a Local and Remote Git Branch](https://phoenixnap.com/kb/how-to-rename-git-branch-local-remote) CONTACT US [Get a Quote](https://phoenixnap.com/contact-us) [Support (1-855-330-1509)](tel:1-855-330-1509) [Sales (1-877-588-5918)](tel:1-877-588-5918) - [Colocation](https://phoenixnap.com/colocation) - [Phoenix](https://phoenixnap.com/colocation/phoenix) - [Ashburn](https://phoenixnap.com/colocation/ashburn) - [Amsterdam](https://phoenixnap.com/colocation/amsterdam) - [Atlanta](https://phoenixnap.com/colocation/atlanta) - [Belgrade](https://phoenixnap.com/colocation/belgrade) - [Singapore](https://phoenixnap.com/colocation/singapore) - [Shipping Instructions](https://phoenixnap.com/colocation/shipping-instructions) RECENT POSTS [jq Command: How to Process and Transform JSON Data](https://phoenixnap.com/kb/jq) [ModuleNotFoundError in Python: Causes and Solutions](https://phoenixnap.com/kb/module-not-found-error-python) [Kill Screen Session in Linux, macOS, Windows](https://phoenixnap.com/kb/kill-screen-session) [Append Dictionary to Dictionary in Python](https://phoenixnap.com/kb/python-merge-dictionaries) ["Invalid Reference Format" Error in Docker: How to Fix](https://phoenixnap.com/kb/docker-invalid-reference-format) - [Servers](https://phoenixnap.com/servers/dedicated) - [Bare Metal Cloud](https://phoenixnap.com/bare-metal-cloud) - [Dedicated Servers](https://phoenixnap.com/servers/dedicated) - [Database Servers](https://phoenixnap.com/servers/database) - [Virtualization Servers](https://phoenixnap.com/servers/virtualization) - [High Performance Computing (HPC) Servers](https://phoenixnap.com/servers/high-performance-computing-hpc) - [Dedicated Streaming Servers](https://phoenixnap.com/servers/streaming) - [Dedicated Game Servers](https://phoenixnap.com/servers/dedicated-game-servers) - [Dedicated Storage Servers](https://phoenixnap.com/servers/storage) - [SQL Server Hosting](https://phoenixnap.com/servers/sql-server-hosting) - [Dedicated Servers in Amsterdam](https://phoenixnap.com/dedicated-servers-amsterdam-netherlands) - [Cloud Servers in Europe](https://phoenixnap.com/cloud-services/cloud-servers-europe) - [Big Memory Infrastructure](https://phoenixnap.com/bare-metal-cloud/big-memory-infrastructure) - [Buy Now](https://admin.phoenixnap.com/wap-pncpadmin-shell/orderForm?bmbPath=/order-form?currencyCode=usd) - [BMC portal](https://signup.bmc.phoenixnap.com/) CLOUD SERVICES - [Data Security Cloud](https://phoenixnap.com/security/data-security-cloud) - [Managed Private Cloud](https://phoenixnap.com/private) - [Object Storage](https://phoenixnap.com/object-storage) - [Solutions](https://phoenixnap.com/infrastructure-solutions) - [Disaster Recovery](https://phoenixnap.com/infrastructure-solutions/disaster-recovery-services) - [Web Hosting Reseller](https://phoenixnap.com/reseller-hosting) - [SaaS Hosting](https://phoenixnap.com/infrastructure-solutions/saas-hosting) COMPLIANCE - [HIPAA Ready Hosting](https://phoenixnap.com/compliance/hipaa-compliant-hosting) - [PCI Compliant Hosting](https://phoenixnap.com/compliance/pci-compliant-hosting) - [Privacy Center](https://phoenixnap.com/) - [Do not sell or share my personal information](https://phoenixnap.com/) NEEDS - [Disaster Recovery Solutions](https://phoenixnap.com/infrastructure-solutions/disaster-recovery-services) - [High Availability Solutions](https://phoenixnap.com/infrastructure-solutions/high-availability-solutions) - [Cloud Evaluation](https://phoenixnap.com/offers/cloud-evaluation-demo) INDUSTRIES - [Web Hosting Providers](https://phoenixnap.com/reseller-hosting) - [Legal](https://phoenixnap.com/infrastructure-solutions/legal-it) - [MSPs & VARs](https://phoenixnap.com/infrastructure-solutions/it-partners) - [Media Hosting](https://phoenixnap.com/infrastructure-solutions/media-hosting) - [Online Gaming](https://phoenixnap.com/infrastructure-solutions/online-gaming) - [SaaS Hosting Solutions](https://phoenixnap.com/infrastructure-solutions/saas-hosting) - [Ecommerce Hosting Solutions](https://phoenixnap.com/infrastructure-solutions/ecommerce-hosting) COMPANY - [About phoenixNAP](https://phoenixnap.com/about) - [IaaS Solutions](https://phoenixnap.com/company/iaas-provider) - [Customer Experience](https://phoenixnap.com/company/customer-experience) - [Platform](https://phoenixnap.com/cloud-services/platform) - [Schedule Virtual Tour](https://phoenixnap.com/phoenix-data-center-virtual-tour) - [Open Source Community](https://phoenixnap.com/company/open-source-community) - [Resource Library](https://phoenixnap.com/company/resource-library) - [Press](https://phoenixnap.com/company/press) - [Events](https://phoenixnap.com/company/it-events) - [Careers](https://techjobs.dev/jobs/) - [Promotions](https://phoenixnap.com/promotions) - [Contact Us](https://phoenixnap.com/contact-us) - [Legal](https://phoenixnap.com/cs/legal/) - [Privacy Policy](https://phoenixnap.com/infrastructure-solutions/legal-it/eu-u-s-data-privacy-framework-program-eu-u-s-dpf-compliant-privacy-policy) - [Terms of Use](https://phoenixnap.com/cs/legal/aup.html) - [DMCA](https://phoenixnap.com/cs/legal/dmca.html) - [GDPR](https://phoenixnap.com/gdpr) - [Sitemap](https://phoenixnap.com/sitemap) - [Blog](https://phoenixnap.com/blog) - [Resources](https://phoenixnap.com/company/resource-library) - [Knowledge Base](https://phoenixnap.com/kb) - [IT Glossary](https://phoenixnap.com/glossary) - [GitHub](https://github.com/phoenixnap) - [RFP Template](https://phoenixnap.com/company/it-resources/data-center-rfp-template) Ā© 2025 phoenixNAP \| Global IT Services. All Rights Reserved.
Readable Markdown
[Home](https://phoenixnap.com/) Ā» [KB](https://phoenixnap.com/kb/) Ā» [SysAdmin](https://phoenixnap.com/kb/category/sysadmin) Ā» Git Revert Commit: How to Undo Last Commit ![](https://secure.gravatar.com/avatar/8d4609e99e6aecc69ce049e18d45f033?s=200&d=mm&r=g) Topics: [Git](https://phoenixnap.com/kb/what-is-git) is a popular project tracking application. As a project progresses through different revisions, those revisions are published as a [commit](https://phoenixnap.com/kb/git-commit). A commit represents a checkpoint, where a copy of the project is saved at a specific point. **This guide shows you how to undo the last commit in git.** ![How can I revert the last commit in git?](https://phoenixnap.com/kb/wp-content/uploads/2021/04/how-to-revert-the-last-commit-in-git.png) Prerequisites An existing project in Git Access to a terminal window/command line **Note:** If you wish to undo a commit to correct an error in the commit message, there is a better way to do it. Learn how to [change a Git commit message](https://phoenixnap.com/kb/git-change-commit-message). How to Revert Commit Git offers many features to manage your project from different historical commits. You can view and revert a previous commit, either published or unpublished. Read on to learn how to identify and revert a published commit. Also, if you want to learn more about Git, check out our article on [how does Git work](https://phoenixnap.com/kb/how-git-works). Identifying the Commit A hash is an alphanumeric code that identifies each commit. Enter the following command to display a commit hash: The hash is necessary to display or manage a specific commit. ![Example of Git commit hash](https://phoenixnap.com/kb/wp-content/uploads/2021/04/find-git-commit-hash-log.png) To analyze the status of your project from a previous commit, use the checkout command: When using a hash with a Git command, there is no need to type it in its entirety. The first few unique characters are enough for Git to identify an entry accurately. **Note:** Find out how to use [Git checkout tags](https://phoenixnap.com/kb/git-checkout-tag) and why they are useful for your development project. Git Revert: Reverting the Last Git Commit Once a commit is uploaded to the server, it creates a more permanent project log. It is not advisable to use **reset** in this case as other developers may have retrieved the updated project already. Deleting updates from one system may cause conflicts with other team members. Instead, use the **revert** command: Make sure to enter the code for the hash you want to revert to. The system asks you to enter a specific commit message for the changes the **revert** command is going to perform. ![Define commit message for the revert action](https://phoenixnap.com/kb/wp-content/uploads/2021/04/commit-message-for-git-revert-command.png) This action creates a new commit based on the one you specified, with a **`revert`** tag. This acts as a log, showing that the commit was published and then reverted (instead of pretending it never happened). **Note:** Learn how to use [Git cherry-pick](https://phoenixnap.com/kb/git-cherry-pick) to select and apply a single commit from one branch to another. Git Reset: Revert Unpublished Commits An **unpublished commit** is an update committed in Git but that has not been uploaded to a server. To reset to a previous commit, before any changes were made: This command wipes the slate clean back to the previous commit. Any changes you made will be lost after using the [reset --hard command](https://phoenixnap.com/kb/git-reset-hard). If you want to preserve your work, you can use [Git stash](https://phoenixnap.com/kb/git-stash): The **`stash`** command saves the work you did, and **`stash pop`** retrieves those changes after the reset. Alternately you can use the following: This command resets the commit history, but it leaves your working directory and staging index as-is. **Note:** Git stash allows users to save their uncommitted files and work in progress to a local stash. Learn how to [Git stash specific files](https://phoenixnap.com/kb/git-stash-specific-files). Git Amend: Modify the Last Commit To modify the most recent commit, use the **`git commit --amend`** command. This command replaces the last commit with the amended commit without altering the snapshot. The **`--amend`** flag is usually used to fix minor mistakes. For instance, you want to commit a couple of files in a single snapshot but forget to add one of the files before committing. This issue is easily solved using the **`--amend`** option. First, you add the missing file using: Then, run the command: The **`--no-edit`** option amends the commit without changing the commit message. Conclusion You now know how to use the **`revert`** and **`reset`** commands to undo changes and revert to a previous commit. Additionally, you have learned how to check the status of your current commit. Remember not to use **`reset`** for published commits as it may lead to version conflicts. Was this article helpful? YesNo
Shard39 (laksa)
Root Hash8557101678125738839
Unparsed URLcom,phoenixnap!/kb/git-revert-last-commit s443