âšī¸ Skipped - page is already crawled
| Filter | Status | Condition | Details |
|---|---|---|---|
| HTTP status | PASS | download_http_code = 200 | HTTP 200 |
| Age cutoff | PASS | download_stamp > now() - 6 MONTH | 0.1 months ago |
| History drop | PASS | isNull(history_drop_reason) | No drop reason |
| Spam/ban | PASS | fh_dont_index != 1 AND ml_spam_score = 0 | ml_spam_score=0 |
| Canonical | PASS | meta_canonical IS NULL OR = '' OR = src_unparsed | Not set |
| Property | Value |
|---|---|
| URL | https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits |
| Last Crawled | 2026-04-15 19:19:16 (3 days ago) |
| First Indexed | 2024-04-03 07:38:40 (2 years ago) |
| HTTP Status Code | 200 |
| Meta Title | Undo and revert pushed Git commits | TheServerSide |
| Meta Description | Need to undo a git push? Here is how to revert a pushed Git commit to a remote GitHub, GitLab or Bitbucket repo. |
| Meta Canonical | null |
| Boilerpipe Text | If you need to undo a
git push
, you only have two options: revert the pushed commit or reset it.
The option you choose to undo a pushed commit depends on the following three factors:
How much control you have over the remote repository.
Whether or not others have fetched or pulled the pushed commit to undo.
Whether or not you want to permanently delete the pushed Git commit.
Choosing the wrong option to undo a
git push
can have serious ramifications upon code shared throughout the team.
How to undo a git push
To undo a pushed Git commit, either of the following two options are valid, although they each come with their own benefits and drawbacks:
Undo the
git push
with a local
git revert
command and push back normally.
Undo the pushed Git commit with a reset and push back with force.
How to revert a pushed commit
If you have pushed a bad commit to GitHub or GitLab, the easiest thing to do is simply issue
Git's revert command
and push back to the server.
git revert
git push origin
When the
git revert
command is issued without any other parameters, it undoes the changes that were part of the previous commit and creates a new commit to denote the change.
When you push back to the server, anyone who looks at your latest commit will not see the code that was part of the prior
git push
.
However, the old commit remains on the server. Anyone can still see the pushed commit you're trying to undo.
Forcefully undo a git push with reset
If you want to permanently delete a pushed Git commit from the server, you must perform a
hard reset
and then push back to the server with force.
git reset --hard
git push --force origin
However, pushing back to the server with force is a destructive move, as it rewrites history to permanently delete the pushed commit.
A hard git reset along with a forced push is one way to undo a pushed Git commit.
If others have pulled from the shared repository and have a copy of the pushed commit you want to undo, they will have problems then next time they
pull or fetch
. Team members might need to perform a
new git clone
to fix a corrupt Git commit history caused by a forced push.
Unfortunately, if the goal is to completely delete the pushed commit, a reset and push with force is the only option.
But to be safe, the best way to undo a git push is with
git revert
. Your fellow developers will appreciate it.
Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development, DevOps and container-based technologies such as Docker, Swarm and Kubernetes. |
| Markdown | [](https://www.theserverside.com/) [ ](https://www.theserverside.com/) [](https://www.techtarget.com/)
[Sign-up now. Start my free, unlimited access.](https://www.theserverside.com/login?fromURL=https%3A%2F%2Fwww.theserverside.com%2Fvideo%2FUndo-and-revert-pushed-Git-commits)
[Login](https://www.theserverside.com/login?fromURL=https%3A%2F%2Fwww.theserverside.com%2Fvideo%2FUndo-and-revert-pushed-Git-commits) [Register](https://www.theserverside.com/register?fromURL=https%3A%2F%2Fwww.theserverside.com%2Fvideo%2FUndo-and-revert-pushed-Git-commits)
[Informa TechTarget](https://www.informatechtarget.com/) [Explore the Network](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [App Architecture](https://www.techtarget.com/searchapparchitecture/)
- [Software Quality](https://www.techtarget.com/searchsoftwarequality/)
- [Cloud Computing](https://www.techtarget.com/searchcloudcomputing/)
- [Security](https://www.techtarget.com/searchsecurity/)
- [AWS](https://www.techtarget.com/searchaws/)
[An Informa TechTarget Publication](https://www.informatechtarget.com/) [Explore our brands](https://www.informatechtarget.com/our-brands)
[RSS](https://www.theserverside.com/rss)
- - [Core Java](https://www.theserverside.com/resources/Core-Java-APIs-and-programming-techniques)
- [DevOps](https://www.theserverside.com/resources/DevOps-driven-cloud-native-app-development)
- [More Topics](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Development](https://www.theserverside.com/resources/Software-development-best-practices-and-processes)
- [Frameworks](https://www.theserverside.com/resources/Front-end-back-end-and-middle-tier-frameworks)
- [Skills and career](https://www.theserverside.com/resources/Professional-skills-development-and-career-advice)
- [Tools](https://www.theserverside.com/resources/Development-tools-for-continuous-software-delivery)
[Other Content](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Videos](https://www.theserverside.com/videos)
- [Definitions](https://www.theserverside.com/definitions)
- [Webinars](https://www.theserverside.com/webinars)
- [Sponsored Sites](https://www.theserverside.com/sponsored_communities)
- [More](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Answers](https://www.theserverside.com/answers)
- [Features](https://www.theserverside.com/features)
- [Opinions](https://www.theserverside.com/opinions)
- [Quizzes](https://www.theserverside.com/quizzes)
- [Tech Accelerators](https://www.theserverside.com/techaccelerators)
- [Tips](https://www.theserverside.com/tips)
- [Tutorials](https://www.theserverside.com/tutorials)
- [Home](https://www.theserverside.com/)
- [DevOps-driven, cloud-native app development](https://www.theserverside.com/resources/DevOps-driven-cloud-native-app-development)
# Undo and revert pushed Git commits
By
- [Cameron McKenzie](https://www.techtarget.com/contributor/Cameron-McKenzie), TechTarget
Published: 02 Apr 2024
Related Videos
- [](https://www.theserverside.com/video/Dont-git-revert-that-last-commit-git-reset-instead)
[Don't git revert that last commit, git reset instead](https://www.theserverside.com/video/Dont-git-revert-that-last-commit-git-reset-instead)
- [](https://www.theserverside.com/video/Full-Git-and-GitHub-tutorial-for-beginners)
[Full Git and GitHub tutorial for beginners](https://www.theserverside.com/video/Full-Git-and-GitHub-tutorial-for-beginners)
- [](https://www.theserverside.com/video/How-to-use-the-git-reset-hard-command-to-change-a-commit-history)
[A git reset hard example: An easy way to undo local commits and shift head](https://www.theserverside.com/video/How-to-use-the-git-reset-hard-command-to-change-a-commit-history)
- [Full Git and GitLab tutorial for beginners](https://www.theserverside.com/video/Full-Git-and-GitLab-tutorial-for-beginners)
- [View All Videos](https://www.theserverside.com/videos)
[View All Videos](https://www.theserverside.com/videos)
- Share this item with your network:
If you need to undo a git push, you only have two options: revert the pushed commit or reset it.
The option you choose to undo a pushed commit depends on the following three factors:
- How much control you have over the remote repository.
- Whether or not others have fetched or pulled the pushed commit to undo.
- Whether or not you want to permanently delete the pushed Git commit.
Choosing the wrong option to undo a git push can have serious ramifications upon code shared throughout the team.
## How to undo a git push
To undo a pushed Git commit, either of the following two options are valid, although they each come with their own benefits and drawbacks:
1. Undo the git push with a local git revert command and push back normally.
2. Undo the pushed Git commit with a reset and push back with force.
## How to revert a pushed commit
If you have pushed a bad commit to GitHub or GitLab, the easiest thing to do is simply issue [Git's revert command](https://www.theserverside.com/tutorial/How-to-git-revert-a-commit-A-simple-undo-changes-example) and push back to the server.
```
git revert
git push origin
```
When the git revert command is issued without any other parameters, it undoes the changes that were part of the previous commit and creates a new commit to denote the change.
When you push back to the server, anyone who looks at your latest commit will not see the code that was part of the prior git push.
However, the old commit remains on the server. Anyone can still see the pushed commit you're trying to undo.
## Forcefully undo a git push with reset
If you want to permanently delete a pushed Git commit from the server, you must perform a [hard reset](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/remove-revert-discard-local-uncommitted-changes-Git-how-to) and then push back to the server with force.
```
git reset --hard
git push --force origin
```
However, pushing back to the server with force is a destructive move, as it rewrites history to permanently delete the pushed commit.

A hard git reset along with a forced push is one way to undo a pushed Git commit.
If others have pulled from the shared repository and have a copy of the pushed commit you want to undo, they will have problems then next time they [pull or fetch](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Git-pull-vs-fetch-Whats-the-difference). Team members might need to perform a [new git clone](https://www.theserverside.com/video/Example-of-how-to-use-the-Git-clone-command) to fix a corrupt Git commit history caused by a forced push.
Unfortunately, if the goal is to completely delete the pushed commit, a reset and push with force is the only option.
But to be safe, the best way to undo a git push is with git revert. Your fellow developers will appreciate it.
*Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development, DevOps and container-based technologies such as Docker, Swarm and Kubernetes.*
Latest TechTarget resources
- [Application Architecture](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Software Quality](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Cloud Computing](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [Security](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
- [AWS](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
[Search App Architecture](https://www.techtarget.com/searchapparchitecture/)
- [AI Agents' role in IT infrastructure is expanding](https://www.techtarget.com/searchapparchitecture/tip/AI-Agents-role-in-IT-infrastructure-is-expanding)
AI agents are moving from passive monitoring to active operators, handling incidents, optimizing infrastructure and forcing teams...
- [Pipeline as Code: Managing CI/CD complexity and sprawl](https://www.techtarget.com/searchapparchitecture/tip/Pipeline-as-Code-Managing-CI-CD-complexity-and-sprawl)
Pipeline as Code enhances CI/CD with automation and consistency but adds complexity. Explore benefits, risks and tools to improve...
- [What repos are trending on GitHub?](https://www.techtarget.com/searchapparchitecture/tip/What-repos-are-trending-on-GitHub)
GitHub Stars are a proxy for developer interest. Weekly GitHub star growth highlights fast-rising repos, giving early insight ...
[Search Software Quality](https://www.techtarget.com/searchsoftwarequality/)
- [Harness Artifact Registry strengthens supply chain governance](https://www.techtarget.com/searchsoftwarequality/news/366639489/Harness-Artifact-Registry-strengthens-supply-chain-governance)
Harness makes its artifact registry generally available beyond early preview customers, with a security twist that could ...
- [AWS Kiro 'user error' reflects common AI coding review gap](https://www.techtarget.com/searchsoftwarequality/news/366639129/AWS-Kiro-user-error-reflects-common-AI-coding-review-gap)
Even internal AWS Kiro users haven't always peer-reviewed AI code output, as evidenced by a reported December outage that ...
- [AWS AI IDE, AgentCore throw down gauntlets for Microsoft](https://www.techtarget.com/searchsoftwarequality/news/366635669/AWS-AI-IDE-AgentCore-throw-down-gauntlets-for-Microsoft)
Kiro emerges as a significant alternative to GitHub Copilot agents, while AWS AgentCore updates square off against Agent 365 in ...
[Search Cloud Computing](https://www.techtarget.com/searchcloudcomputing/)
- [AI is changing cloud operations, but not in the way orgs expect](https://www.techtarget.com/searchcloudcomputing/feature/AI-is-changing-cloud-operations-but-not-in-the-way-orgs-expect)
The defining question for organizations today is no longer whether AI can be deployed, but whether it can be operated reliably, ...
- [The hidden costs of technical debt in infrastructure](https://www.techtarget.com/searchcloudcomputing/tip/The-hidden-costs-of-technical-debt-in-infrastructure)
Technical debt is a strategic leadership issue rather than a budgeted maintenance concern. Orgs that actively manage technical ...
- [Is your cloud storage ready for AI workloads?](https://www.techtarget.com/searchcloudcomputing/tip/Is-your-cloud-storage-ready-for-AI-workloads)
Cloud storage design directly impacts AI performance, scalability and cost. Learn how to choose the right storage types, optimize...
[Search Security](https://www.techtarget.com/searchsecurity/)
- [News brief: Iranian cyberattacks target U.S. water, energy](https://www.techtarget.com/searchsecurity/news/366641657/News-brief-Iranian-cyberattacks-target-US-water-energy)
Check out the latest security news from TechTarget SearchSecurity's sister sites, Cybersecurity Dive and Dark Reading.
- [Human vs. AI: Debates shape RSAC 2026 cybersecurity trends](https://www.darkreading.com/cybersecurity-operations/human-vs-ai-debates-shape-rsac-2026-cybersecurity-trends)
As AI dominated RSAC 2026, CISOs and industry leaders debated its role in security, from agentic applications to the challenges ...
- [CISO checklist: Cybersecurity platform or marketing ploy?](https://www.techtarget.com/searchsecurity/feature/CISO-checklist-Cybersecurity-platform-or-marketing-ploy)
The cybersecurity market is booming with countless vendors claiming to offer unified platforms. Here's how to separate the real ...
[Search AWS](https://www.techtarget.com/searchaws/)
- [Compare Datadog vs. New Relic for IT monitoring in 2024](https://www.techtarget.com/searchaws/tip/Compare-CloudWatch-vs-Datadog-and-New-Relic-for-AWS-monitoring)
Compare Datadog vs. New Relic capabilities including alerts, log management, incident management and more. Learn which tool is ...
- [AWS Control Tower aims to simplify multi-account management](https://www.techtarget.com/searchaws/tip/AWS-Control-Tower-aims-to-simplify-multi-account-management)
Many organizations struggle to manage their vast collection of AWS accounts, but Control Tower can help. The service automates ...
- [Break down the Amazon EKS pricing model](https://www.techtarget.com/searchaws/tip/Compare-EKS-pricing-to-other-managed-Kubernetes-services)
There are several important variables within the Amazon EKS pricing model. Dig into the numbers to ensure you deploy the service ...
- Follow:
- [About Us](https://www.informatechtarget.com/editorial/)
- [Editorial Ethics Policy](https://www.techtarget.com/techtarget-editorial-ethics-policy)
- [Meet The Editors](https://www.techtarget.com/editorial-contacts)
- [Contact Us](https://www.informatechtarget.com/contact-us/)
- [Advertisers](https://www.informatechtarget.com/for-advertisers/)
- [Partner with Us](https://www.informatechtarget.com/partner-with-us/)
- [Media Kit](https://www.informatechtarget.com/wp-content/uploads/2023/09/TechTarget-Media-Kit-Handout-with-product-descriptions.pdf)
- [Corporate Site](https://www.informatechtarget.com/)
- [Contributors](https://www.theserverside.com/contributors)
- [Reprints](https://licensing.ygsgroup.com/ygspublishersolutions/)
- [Answers](https://www.theserverside.com/answers)
- [Definitions](https://www.theserverside.com/definitions)
- [E-Products](https://www.theserverside.com/eproducts)
- [Events](https://www.brighttalk.com/summits)
- [Features](https://www.theserverside.com/features)
- [Guides](https://www.theserverside.com/guides)
- [Opinions](https://www.theserverside.com/opinions)
- [Photo Stories](https://www.theserverside.com/photostories)
- [Quizzes](https://www.theserverside.com/quizzes)
- [Tips](https://www.theserverside.com/tips)
- [Tutorials](https://www.theserverside.com/tutorials)
- [Videos](https://www.theserverside.com/videos)
[Š2026 TechTarget](https://www.informatechtarget.com/terms-of-use), Inc. d/b/a Informa TechTarget. All Rights Reserved.
[Privacy Policy](https://www.informatechtarget.com/privacy-policy/)
[Cookie Preferences](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
[Cookie Preferences](https://www.theserverside.com/video/Undo-and-revert-pushed-Git-commits)
[Do Not Sell or Share My Personal Information](https://techtarget.zendesk.com/hc/en-us/requests/new?ticket_form_id=360004852434)
Close
 |
| Readable Markdown | If you need to undo a git push, you only have two options: revert the pushed commit or reset it.
The option you choose to undo a pushed commit depends on the following three factors:
- How much control you have over the remote repository.
- Whether or not others have fetched or pulled the pushed commit to undo.
- Whether or not you want to permanently delete the pushed Git commit.
Choosing the wrong option to undo a git push can have serious ramifications upon code shared throughout the team.
## How to undo a git push
To undo a pushed Git commit, either of the following two options are valid, although they each come with their own benefits and drawbacks:
1. Undo the git push with a local git revert command and push back normally.
2. Undo the pushed Git commit with a reset and push back with force.
## How to revert a pushed commit
If you have pushed a bad commit to GitHub or GitLab, the easiest thing to do is simply issue [Git's revert command](https://www.theserverside.com/tutorial/How-to-git-revert-a-commit-A-simple-undo-changes-example) and push back to the server.
```
git revert
git push origin
```
When the git revert command is issued without any other parameters, it undoes the changes that were part of the previous commit and creates a new commit to denote the change.
When you push back to the server, anyone who looks at your latest commit will not see the code that was part of the prior git push.
However, the old commit remains on the server. Anyone can still see the pushed commit you're trying to undo.
## Forcefully undo a git push with reset
If you want to permanently delete a pushed Git commit from the server, you must perform a [hard reset](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/remove-revert-discard-local-uncommitted-changes-Git-how-to) and then push back to the server with force.
```
git reset --hard
git push --force origin
```
However, pushing back to the server with force is a destructive move, as it rewrites history to permanently delete the pushed commit.

A hard git reset along with a forced push is one way to undo a pushed Git commit.
If others have pulled from the shared repository and have a copy of the pushed commit you want to undo, they will have problems then next time they [pull or fetch](https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Git-pull-vs-fetch-Whats-the-difference). Team members might need to perform a [new git clone](https://www.theserverside.com/video/Example-of-how-to-use-the-Git-clone-command) to fix a corrupt Git commit history caused by a forced push.
Unfortunately, if the goal is to completely delete the pushed commit, a reset and push with force is the only option.
But to be safe, the best way to undo a git push is with git revert. Your fellow developers will appreciate it.
*Cameron McKenzie has been a Java EE software engineer for 20 years. His current specialties include Agile development, DevOps and container-based technologies such as Docker, Swarm and Kubernetes.* |
| Shard | 23 (laksa) |
| Root Hash | 7434987543936799023 |
| Unparsed URL | com,theserverside!www,/video/Undo-and-revert-pushed-Git-commits s443 |