đŸ•·ïž Crawler Inspector

URL Lookup

Direct Parameter Lookup

Raw Queries and Responses

1. Shard Calculation

Query:
Response:
Calculated Shard: 29 (from laksa065)

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
5 days ago
đŸ€–
ROBOTS ALLOWED

Page Info Filters

FilterStatusConditionDetails
HTTP statusPASSdownload_http_code = 200HTTP 200
Age cutoffPASSdownload_stamp > now() - 6 MONTH0.2 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.gitkraken.com/learn/git/problems/undo-git-commit
Last Crawled2026-04-07 12:51:54 (5 days ago)
First Indexed2021-10-15 18:27:58 (4 years ago)
HTTP Status Code200
Meta TitleUndo Git Commit | How do you undo your last Git commit?
Meta DescriptionLearn how to Git undo a commit, including how to undo your last Git commit, Git undo a local commmit, and how to Git undo your last commit and keep the changes.
Meta Canonicalnull
Boilerpipe Text
Even for the more experienced and diligent developers, mistakes happen when working with Git repositories. So what is the best step to take after you make a mistake in Git? Well, that depends.  Depending on the scenario at hand, the best process for fixing your mistake might be to undo it all together. But beware: if you aren’t careful, attempting to fix a mistake the wrong way can cause you to lose important work, introduce code conflicts, and more.  Thankfully, Git does offer some tools to help you undo mistakes specifically that are introduced with a new commit. Let’s look at all of the options you have for how to undo a Git commit in GitKraken Git client , first in the GUI before looking at the process in the CLI .  “Thank you @GitKraken for the undo feature, accidentally discarded all my changes but now they are back again 😃” – @offset1337 Download GitKraken Desktop Free Available on: Do you need to undo a Git commit? Before you begin the process of undoing a Git commit, you should make sure you actually want to undo something, rather than just fix or edit something. If you do need to edit your last commit, you can amend the Git commit instead. Amending a Git commit allows you to correct the previous commit message and add more changes to it. Undo Last Git Commit Let’s say that you’ve committed the wrong files, but you haven’t pushed your code changes to your Git remote yet, so you need to Git undo the local commit. How can you undo the last commit, or group of commits, from your local Git repository?  Undo Last Git Commit in GitKraken When you make a mistake in GitKraken, the solution is just one-click away. If you make a mistake with your last commit and wish to undo the last Git commit before you push, you can simply click the magical Undo button at the toolbar at the top of the UI.  Better yet, if you realize that you actually did not want to undo your last Git commit, you can click the Redo button to undo your undo. It’s important to remember, using the Undo button will work to undo a commit if you haven’t performed any other actions, but let’s say you’ve created a Git branch , for example. In this case, using the Undo button would undo the branch, not the commit. To undo a Git commit after you’ve performed another action in GitKraken, you will have to use the Git reset feature. Simply right-click on the commit from the central graph and select Reset -> Soft to keep all of the changes, or Reset -> Hard to discard the changes, if you’re sure you won’t need them again in the future. Whether you prefer to use a GUI or CLI, GitKraken makes undoing actions, like undoing your last commit, easy and safe so you can have more confidence in your workflow. Download GitKraken Client Free Undo Last Git Commit in the GitKraken CLI Now, let’s go over the process of how to undo your last Git commit using the GitKraken CLI . Git Reset Compared to reverting a Git commit , Git reset allows you to move back in time to a particular commit, and reset your active position to a selected commit. With Git reset, you have two options: you can Git reset “soft” or Git reset “hard”.  How do you Git undo your last commit and keep changes?  If you want to undo your last Git commit but keep the changes, a soft Git reset will do the trick. Using the --soft flag will ensure that the changes in undone revisions are preserved. You can find these changes as uncommitted local modifications in your working copy after you perform a soft Git reset. If you’re using the GitKraken CLI, you can simply type:  $  git reset --soft HEAD~1 Git reset should be used with care. Let’s say, for example, that you travel back in time to a commit far back in your history; all of the commits you passed along the way may now end up in a dangling state where they exist, but nothing references them. And if you perform a “hard” reset, you risk losing work that wasn’t backed up properly. You should only perform a hard Git reset if you are positive you don’t need those changes anymore.  $  git reset --hard HEAD~1 As a Git best practice, you should always avoid doing anything that requires a force push, which will rewrite the history of your main branch(es).  Get ready to revolutionize your workflow with Git by having the power of a GUI and CLI at your fingertips, enabling you to choose the best tool for each action according to your preference. Download GitKraken Client Free
Markdown
![](https://www.gitkraken.com/wp-content/uploads/2026/01/%F0%9F%8E%89-NEW-YEAR-Sale.png) GET 50% OFF GitKraken Pro! Ends Soon [Take Advantage to Save](https://www.gitkraken.com/new-year-sale-2026) ![](https://www.gitkraken.com/wp-content/uploads/2026/01/Group-22113-2.png) [Claim 50% off →](https://www.gitkraken.com/new-year-sale-2026/) [![](https://www.gitkraken.com/wp-content/uploads/2025/03/gitkraken-logo-stencil-monochrome-light.svg)](https://www.gitkraken.com/) - [Tools For How You Work](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - for developers - [![](https://www.gitkraken.com/wp-content/uploads/2024/05/gkd-nav.svg) GitKraken Desktop](https://www.gitkraken.com/git-client) - [![](https://www.gitkraken.com/wp-content/uploads/2024/11/product-vs-code-rainbow.svg) GitLens for IDEs](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [VS Code](https://www.gitkraken.com/gitlens) - [Cursor](https://www.gitkraken.com/gitlens/cursor) - [Windsurf](https://www.gitkraken.com/gitlens/windsurf) - [Trae](https://www.gitkraken.com/gitlens/trae) - [Kiro](https://www.gitkraken.com/gitlens/kiro) - *Jet Brains (Coming Soon)* - [![](https://www.gitkraken.com/wp-content/uploads/2024/05/gk-cli-nav.svg) GitKraken CLI](https://www.gitkraken.com/cli) - [![](https://www.gitkraken.com/wp-content/uploads/2025/10/Union-6.png) GitKraken MCP](https://www.gitkraken.com/mcp) for engineering leaders - [![](https://www.gitkraken.com/wp-content/uploads/2025/10/Vector-Stroke-1.png) GitKraken Insights](https://www.gitkraken.com/insights) - [![](https://staging-www.gitkraken.com/wp-content/uploads/2025/10/Group-22015-1.png) Dev Team Automations](https://www.gitkraken.com/features/automations) - [![](https://staging-www.gitkraken.com/wp-content/uploads/2025/10/Subtract.png) AI & Security Controls](https://www.gitkraken.com/solutions/enterprise-git-security) - [![](https://www.gitkraken.com/wp-content/uploads/2024/05/gij-nav.svg) Git Integration for Jira](https://www.gitkraken.com/git-integration-for-jira) - [Features](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - ## Built for Teams A DevEx platform that’s built for team velocity & greater collaboration. ![](https://staging-www.gitkraken.com/wp-content/uploads/2024/09/Vector.svg) Supercharge Your Dev Team \> ## Enterprise Grade Solutions designed for large-scale security, privacy & control. ![](https://staging-www.gitkraken.com/wp-content/uploads/2024/09/Vector-1.svg) Secure Your Dev Team \> - [Commit Graph](https://www.gitkraken.com/features/commit-graph) - [Launchpad](https://www.gitkraken.com/features/launchpad) - [Workspaces](https://www.gitkraken.com/features/workspaces) - [Code Suggest](https://www.gitkraken.com/features/code-suggestions) - [Cloud Patches](https://www.gitkraken.com/features/cloud-patches) - [GitKraken AI](https://www.gitkraken.com/features/git-ai) - [Merge Tool](https://www.gitkraken.com/features/merge-conflict-resolution-tool) - [Automations](https://www.gitkraken.com/features/automations) - [Codemaps](https://www.gitkraken.com/features/code-dependency-mapping) - [Security Controls](https://www.gitkraken.com/features/security-controls) - [Solutions](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - - [Git Simplified](https://www.gitkraken.com/solutions/git-for-beginners) - [Individual Productivity](https://www.gitkraken.com/solutions/developer-productivity) - [Team Collaboration](https://www.gitkraken.com/solutions/development-team-collaboration) - [PR & Code Review](https://www.gitkraken.com/solutions/code-review) - [Developer Experience](https://www.gitkraken.com/solutions/developer-experience) - [Continuous Understanding](https://www.gitkraken.com/solutions/continuous-understanding) - [Sprint Planning & Execution](https://www.gitkraken.com/solutions/jira-sprint-planning-execution) - [Team Productivity](https://www.gitkraken.com/solutions/jira-developer-productivity) - [Dev Visibility](https://www.gitkraken.com/solutions/jira-development-visibility) - [Jira Git Security](https://www.gitkraken.com/solutions/jira-git-security) - [Security & Admin](https://www.gitkraken.com/solutions/enterprise-git-security) - [Git Resources](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - - [GitKon](https://gitkon.com/) - [Workshops](https://www.gitkraken.com/workshops) - [Learn Git Library](https://www.gitkraken.com/learn/git) - [Git Blog](https://www.gitkraken.com/blog) - [Refer and Earn 💰](https://www.gitkraken.com/referral-program) - [Sample Customers](https://www.gitkraken.com/sample-customers) - [Customer Stories](https://www.gitkraken.com/media#customer-stories) - [Developer Problems](https://www.gitkraken.com/developer-problems) - [GitKraken Labs](https://www.gitkraken.com/labs) - [Help Center](https://help.gitkraken.com/) - [Pricing](https://www.gitkraken.com/pricing) - [Sign In](https://gitkraken.dev/login?source=marketing_page) - [GitKraken Desktop features](https://www.gitkraken.com/git-client) - [GitLens features](https://www.gitkraken.com/gitlens) - [Git Integration for Jira features](https://www.gitkraken.com/git-integration-for-jira) - [GiKraken CLI features](https://www.gitkraken.com/cli) - [Pricing](https://www.gitkraken.com/pricing) - [Sign up to start a free trial](https://gitkraken.dev/trial?source=marketing_page) [Home](https://www.gitkraken.com/) » [Learn](https://www.gitkraken.com/learn) » [Git](https://www.gitkraken.com/learn/git) » [Problems & Solutions](https://www.gitkraken.com/learn/git/problems) » Undo Git Commit - [Learn Git Home](https://www.gitkraken.com/learn/git) - [Git Concepts](https://www.gitkraken.com/learn/git#concepts) - [Git Add](https://www.gitkraken.com/learn/git/git-add) - [Git Branch](https://www.gitkraken.com/learn/git/branch) - [Git Checkout](https://www.gitkraken.com/learn/git/git-checkout) - [Git Cherry Pick](https://www.gitkraken.com/learn/git/cherry-pick) - [Git Clone](https://www.gitkraken.com/learn/git/git-clone) - [Git Commit](https://www.gitkraken.com/learn/git/commit) - [Git Config](https://www.gitkraken.com/learn/git/git-config) - [Git Diff](https://www.gitkraken.com/learn/git/git-diff) - [Git Download](https://www.gitkraken.com/learn/git/git-download) - [Git Fetch](https://www.gitkraken.com/learn/git/git-fetch) - [Git Flow](https://www.gitkraken.com/learn/git/git-flow) - [Git LFS](https://www.gitkraken.com/learn/git/git-lfs) - [Git Merge](https://www.gitkraken.com/learn/git/git-merge) - [Git Patch](https://www.gitkraken.com/learn/git/git-patch) - [Git Push](https://www.gitkraken.com/learn/git/git-push) - [Git Rebase](https://www.gitkraken.com/learn/git/git-rebase) - [Git Remote](https://www.gitkraken.com/learn/git/git-remote) - [Git Reset](https://www.gitkraken.com/learn/git/git-reset) - [Git Squash](https://www.gitkraken.com/learn/git/git-squash) - [Git Stash](https://www.gitkraken.com/learn/git/git-stash) - [Git Worktree](https://www.gitkraken.com/learn/git/git-worktree) - [Git Tutorials](https://www.gitkraken.com/learn/git/tutorials) - [Beginner Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [What is a Git Repository?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-git-repository) - [What is a Git Commit?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-commit) - [How to Git Commit](https://www.gitkraken.com/learn/git/tutorials/how-to-git-commit) - [What is a Git Remote?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-remote) - [How to Git Branch](https://www.gitkraken.com/learn/git/tutorials/how-to-git-branch) - [How to Create a Git Branch](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How to Delete a Git Branch](https://www.gitkraken.com/learn/git/tutorials/delete-git-branch) - [How to Rename a Git Branch](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How Git SSH Works](https://www.gitkraken.com/learn/git/tutorials/how-git-ssh-works) - [How Git Diff Works](https://www.gitkraken.com/learn/git/tutorials/what-is-a-diff) - [What is Git Checkout?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-checkout) - [What is Git Pull?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-pull) - [Intermediate Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Git Merge](https://www.gitkraken.com/learn/git/tutorials/how-to-git-merge) - [How to Git Stash](https://www.gitkraken.com/learn/git/tutorials/how-to-git-stash) - [How to Create Git Hooks](https://www.gitkraken.com/learn/git/tutorials/how-to-create-git-hooks) - [How to Git Squash](https://www.gitkraken.com/learn/git/tutorials/what-is-git-squash) - [What is a Pull Request in Git?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-pull-request-in-git) - [How to Git Cherry Pick](https://www.gitkraken.com/learn/git/tutorials/how-to-cherry-pick-git) - [What is Git Rebase?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-rebase) - [Advanced Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Resolve a Merge Conflict in Git](https://www.gitkraken.com/learn/git/tutorials/how-to-resolve-merge-conflict-in-git) - [What is Git LFS?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-lfs) - [What is a Git Submodule?](https://www.gitkraken.com/learn/git/tutorials/git-submodule-how-to) - [Git Best Practices](https://www.gitkraken.com/learn/git/best-practices) - [Clean Up History After Cherry Picking](https://www.gitkraken.com/learn/git/best-practices/clean-up-history-after-cherry-picking) - [Writing a Good Git Commit Message](https://www.gitkraken.com/learn/git/best-practices/git-commit-message) - [What is the best Git branch strategy?](https://www.gitkraken.com/learn/git/best-practices/git-branch-strategy) - [Git Commands](https://www.gitkraken.com/learn/git/commands) - [Git Definitions](https://www.gitkraken.com/learn/git/definitions) - [Git Problems and Solutions](https://www.gitkraken.com/learn/git/problems) - [Branching](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you create a branch in Git?](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How do you rename a Git branch?](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How do you switch a Git branch?](https://www.gitkraken.com/learn/git/problems/switch-git-branch) - [How do you checkout a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/git-checkout-remote-branch) - [How do you delete a local branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-local-git-branch) - [How do you delete a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-remote-git-branch) - [How do you view your Git branch list?](https://www.gitkraken.com/learn/git/problems/git-branch-list) - [How do you merge a Git branch?](https://www.gitkraken.com/learn/git/problems/merge-git-branch) - [How do you set an upstream branch in Git?](https://www.gitkraken.com/learn/git/problems/git-set-upstream-branch) - [Git Pull Remote Branch](https://www.gitkraken.com/learn/git/problems/pull-remote-git-branch) - [Checkout](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Checkout Commit](https://www.gitkraken.com/learn/git/problems/git-checkout-commit) - [How do you checkout a Git tag?](https://www.gitkraken.com/learn/git/problems/git-checkout-tag) - [Cherry Pick](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Can you cherry pick from another repository in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-from-another-repository) - [Can you cherry pick multiple commits in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-multiple-commits) - [Clone](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git clone a branch?](https://www.gitkraken.com/learn/git/problems/git-clone-branch) - [Commit](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you revert a commit in Git?](https://www.gitkraken.com/learn/git/problems/revert-git-commit) - [How do you amend a Git commit message?](https://www.gitkraken.com/learn/git/problems/git-commit-amend) - [How do you undo a Git commit?](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Merge](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you undo a Git merge?](https://www.gitkraken.com/learn/git/problems/undo-git-merge) - [Pull](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Pull vs Fetch](https://www.gitkraken.com/learn/git/problems/git-pull-vs-fetch) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you Git pull force?](https://www.gitkraken.com/learn/git/problems/git-pull-force) - [How do you Git pull rebase?](https://www.gitkraken.com/learn/git/problems/git-pull-rebase) - [Push](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git push a tag?](https://www.gitkraken.com/learn/git/problems/git-push-tag) - [How do you Git push to a remote branch?](https://www.gitkraken.com/learn/git/problems/git-push-to-remote-branch) - [How do you force a Git push?](https://www.gitkraken.com/learn/git/problems/git-push-force) - [Rebase](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you perform an interactive rebase?](https://www.gitkraken.com/learn/git/problems/git-interactive-rebase) - [When to Git rebase vs merge?](https://www.gitkraken.com/learn/git/problems/git-rebase-vs-merge) - [How do you Git rebase a branch?](https://www.gitkraken.com/learn/git/problems/git-rebase-branch) - [SSH](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [GitHub](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you delete a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-delete-repository) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [How do you fork a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-how-to-fork) - [Learn Git Home](https://www.gitkraken.com/learn/git) - [Git Concepts](https://www.gitkraken.com/learn/git#concepts) - [Git Add](https://www.gitkraken.com/learn/git/git-add) - [Git Branch](https://www.gitkraken.com/learn/git/branch) - [Git Checkout](https://www.gitkraken.com/learn/git/git-checkout) - [Git Cherry Pick](https://www.gitkraken.com/learn/git/cherry-pick) - [Git Clone](https://www.gitkraken.com/learn/git/git-clone) - [Git Commit](https://www.gitkraken.com/learn/git/commit) - [Git Config](https://www.gitkraken.com/learn/git/git-config) - [Git Diff](https://www.gitkraken.com/learn/git/git-diff) - [Git Download](https://www.gitkraken.com/learn/git/git-download) - [Git Fetch](https://www.gitkraken.com/learn/git/git-fetch) - [Git Flow](https://www.gitkraken.com/learn/git/git-flow) - [Git LFS](https://www.gitkraken.com/learn/git/git-lfs) - [Git Merge](https://www.gitkraken.com/learn/git/git-merge) - [Git Patch](https://www.gitkraken.com/learn/git/git-patch) - [Git Push](https://www.gitkraken.com/learn/git/git-push) - [Git Rebase](https://www.gitkraken.com/learn/git/git-rebase) - [Git Remote](https://www.gitkraken.com/learn/git/git-remote) - [Git Reset](https://www.gitkraken.com/learn/git/git-reset) - [Git Squash](https://www.gitkraken.com/learn/git/git-squash) - [Git Stash](https://www.gitkraken.com/learn/git/git-stash) - [Git Worktree](https://www.gitkraken.com/learn/git/git-worktree) - [Git Tutorials](https://www.gitkraken.com/learn/git/tutorials) - [Beginner Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [What is a Git Repository?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-git-repository) - [What is a Git Commit?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-commit) - [How to Git Commit](https://www.gitkraken.com/learn/git/tutorials/how-to-git-commit) - [What is a Git Remote?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-remote) - [How to Git Branch](https://www.gitkraken.com/learn/git/tutorials/how-to-git-branch) - [How to Create a Git Branch](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How to Delete a Git Branch](https://www.gitkraken.com/learn/git/tutorials/delete-git-branch) - [How to Rename a Git Branch](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How Git SSH Works](https://www.gitkraken.com/learn/git/tutorials/how-git-ssh-works) - [How Git Diff Works](https://www.gitkraken.com/learn/git/tutorials/what-is-a-diff) - [What is Git Checkout?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-checkout) - [What is Git Pull?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-pull) - [Intermediate Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Git Merge](https://www.gitkraken.com/learn/git/tutorials/how-to-git-merge) - [How to Git Stash](https://www.gitkraken.com/learn/git/tutorials/how-to-git-stash) - [How to Create Git Hooks](https://www.gitkraken.com/learn/git/tutorials/how-to-create-git-hooks) - [How to Git Squash](https://www.gitkraken.com/learn/git/tutorials/what-is-git-squash) - [What is a Pull Request in Git?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-pull-request-in-git) - [How to Git Cherry Pick](https://www.gitkraken.com/learn/git/tutorials/how-to-cherry-pick-git) - [What is Git Rebase?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-rebase) - [Advanced Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Resolve a Merge Conflict in Git](https://www.gitkraken.com/learn/git/tutorials/how-to-resolve-merge-conflict-in-git) - [What is Git LFS?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-lfs) - [What is a Git Submodule?](https://www.gitkraken.com/learn/git/tutorials/git-submodule-how-to) - [Git Best Practices](https://www.gitkraken.com/learn/git/best-practices) - [Clean Up History After Cherry Picking](https://www.gitkraken.com/learn/git/best-practices/clean-up-history-after-cherry-picking) - [Writing a Good Git Commit Message](https://www.gitkraken.com/learn/git/best-practices/git-commit-message) - [What is the best Git branch strategy?](https://www.gitkraken.com/learn/git/best-practices/git-branch-strategy) - [Git Commands](https://www.gitkraken.com/learn/git/commands) - [Git Definitions](https://www.gitkraken.com/learn/git/definitions) - [Git Problems and Solutions](https://www.gitkraken.com/learn/git/problems) - [Branching](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you create a branch in Git?](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How do you rename a Git branch?](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How do you switch a Git branch?](https://www.gitkraken.com/learn/git/problems/switch-git-branch) - [How do you checkout a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/git-checkout-remote-branch) - [How do you delete a local branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-local-git-branch) - [How do you delete a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-remote-git-branch) - [How do you view your Git branch list?](https://www.gitkraken.com/learn/git/problems/git-branch-list) - [How do you merge a Git branch?](https://www.gitkraken.com/learn/git/problems/merge-git-branch) - [How do you set an upstream branch in Git?](https://www.gitkraken.com/learn/git/problems/git-set-upstream-branch) - [Git Pull Remote Branch](https://www.gitkraken.com/learn/git/problems/pull-remote-git-branch) - [Checkout](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Checkout Commit](https://www.gitkraken.com/learn/git/problems/git-checkout-commit) - [How do you checkout a Git tag?](https://www.gitkraken.com/learn/git/problems/git-checkout-tag) - [Cherry Pick](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Can you cherry pick from another repository in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-from-another-repository) - [Can you cherry pick multiple commits in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-multiple-commits) - [Clone](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git clone a branch?](https://www.gitkraken.com/learn/git/problems/git-clone-branch) - [Commit](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you revert a commit in Git?](https://www.gitkraken.com/learn/git/problems/revert-git-commit) - [How do you amend a Git commit message?](https://www.gitkraken.com/learn/git/problems/git-commit-amend) - [How do you undo a Git commit?](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Merge](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you undo a Git merge?](https://www.gitkraken.com/learn/git/problems/undo-git-merge) - [Pull](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Pull vs Fetch](https://www.gitkraken.com/learn/git/problems/git-pull-vs-fetch) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you Git pull force?](https://www.gitkraken.com/learn/git/problems/git-pull-force) - [How do you Git pull rebase?](https://www.gitkraken.com/learn/git/problems/git-pull-rebase) - [Push](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git push a tag?](https://www.gitkraken.com/learn/git/problems/git-push-tag) - [How do you Git push to a remote branch?](https://www.gitkraken.com/learn/git/problems/git-push-to-remote-branch) - [How do you force a Git push?](https://www.gitkraken.com/learn/git/problems/git-push-force) - [Rebase](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you perform an interactive rebase?](https://www.gitkraken.com/learn/git/problems/git-interactive-rebase) - [When to Git rebase vs merge?](https://www.gitkraken.com/learn/git/problems/git-rebase-vs-merge) - [How do you Git rebase a branch?](https://www.gitkraken.com/learn/git/problems/git-rebase-branch) - [SSH](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [GitHub](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you delete a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-delete-repository) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [How do you fork a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-how-to-fork) - [Learn Git Home](https://www.gitkraken.com/learn/git) - [Git Concepts](https://www.gitkraken.com/learn/git#concepts) - [Git Add](https://www.gitkraken.com/learn/git/git-add) - [Git Branch](https://www.gitkraken.com/learn/git/branch) - [Git Checkout](https://www.gitkraken.com/learn/git/git-checkout) - [Git Cherry Pick](https://www.gitkraken.com/learn/git/cherry-pick) - [Git Clone](https://www.gitkraken.com/learn/git/git-clone) - [Git Commit](https://www.gitkraken.com/learn/git/commit) - [Git Config](https://www.gitkraken.com/learn/git/git-config) - [Git Diff](https://www.gitkraken.com/learn/git/git-diff) - [Git Download](https://www.gitkraken.com/learn/git/git-download) - [Git Fetch](https://www.gitkraken.com/learn/git/git-fetch) - [Git Flow](https://www.gitkraken.com/learn/git/git-flow) - [Git LFS](https://www.gitkraken.com/learn/git/git-lfs) - [Git Merge](https://www.gitkraken.com/learn/git/git-merge) - [Git Patch](https://www.gitkraken.com/learn/git/git-patch) - [Git Push](https://www.gitkraken.com/learn/git/git-push) - [Git Rebase](https://www.gitkraken.com/learn/git/git-rebase) - [Git Remote](https://www.gitkraken.com/learn/git/git-remote) - [Git Reset](https://www.gitkraken.com/learn/git/git-reset) - [Git Squash](https://www.gitkraken.com/learn/git/git-squash) - [Git Stash](https://www.gitkraken.com/learn/git/git-stash) - [Git Worktree](https://www.gitkraken.com/learn/git/git-worktree) - [Git Tutorials](https://www.gitkraken.com/learn/git/tutorials) - [Beginner Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [What is a Git Repository?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-git-repository) - [What is a Git Commit?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-commit) - [How to Git Commit](https://www.gitkraken.com/learn/git/tutorials/how-to-git-commit) - [What is a Git Remote?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-remote) - [How to Git Branch](https://www.gitkraken.com/learn/git/tutorials/how-to-git-branch) - [How to Create a Git Branch](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How to Delete a Git Branch](https://www.gitkraken.com/learn/git/tutorials/delete-git-branch) - [How to Rename a Git Branch](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How Git SSH Works](https://www.gitkraken.com/learn/git/tutorials/how-git-ssh-works) - [How Git Diff Works](https://www.gitkraken.com/learn/git/tutorials/what-is-a-diff) - [What is Git Checkout?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-checkout) - [What is Git Pull?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-pull) - [Intermediate Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Git Merge](https://www.gitkraken.com/learn/git/tutorials/how-to-git-merge) - [How to Git Stash](https://www.gitkraken.com/learn/git/tutorials/how-to-git-stash) - [How to Create Git Hooks](https://www.gitkraken.com/learn/git/tutorials/how-to-create-git-hooks) - [How to Git Squash](https://www.gitkraken.com/learn/git/tutorials/what-is-git-squash) - [What is a Pull Request in Git?](https://www.gitkraken.com/learn/git/tutorials/what-is-a-pull-request-in-git) - [How to Git Cherry Pick](https://www.gitkraken.com/learn/git/tutorials/how-to-cherry-pick-git) - [What is Git Rebase?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-rebase) - [Advanced Tutorials](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How to Resolve a Merge Conflict in Git](https://www.gitkraken.com/learn/git/tutorials/how-to-resolve-merge-conflict-in-git) - [What is Git LFS?](https://www.gitkraken.com/learn/git/tutorials/what-is-git-lfs) - [What is a Git Submodule?](https://www.gitkraken.com/learn/git/tutorials/git-submodule-how-to) - [Git Best Practices](https://www.gitkraken.com/learn/git/best-practices) - [Clean Up History After Cherry Picking](https://www.gitkraken.com/learn/git/best-practices/clean-up-history-after-cherry-picking) - [Writing a Good Git Commit Message](https://www.gitkraken.com/learn/git/best-practices/git-commit-message) - [What is the best Git branch strategy?](https://www.gitkraken.com/learn/git/best-practices/git-branch-strategy) - [Git Commands](https://www.gitkraken.com/learn/git/commands) - [Git Definitions](https://www.gitkraken.com/learn/git/definitions) - [Git Problems and Solutions](https://www.gitkraken.com/learn/git/problems) - [Branching](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you create a branch in Git?](https://www.gitkraken.com/learn/git/problems/create-git-branch) - [How do you rename a Git branch?](https://www.gitkraken.com/learn/git/problems/rename-git-branch) - [How do you switch a Git branch?](https://www.gitkraken.com/learn/git/problems/switch-git-branch) - [How do you checkout a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/git-checkout-remote-branch) - [How do you delete a local branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-local-git-branch) - [How do you delete a remote branch in Git?](https://www.gitkraken.com/learn/git/problems/delete-remote-git-branch) - [How do you view your Git branch list?](https://www.gitkraken.com/learn/git/problems/git-branch-list) - [How do you merge a Git branch?](https://www.gitkraken.com/learn/git/problems/merge-git-branch) - [How do you set an upstream branch in Git?](https://www.gitkraken.com/learn/git/problems/git-set-upstream-branch) - [Git Pull Remote Branch](https://www.gitkraken.com/learn/git/problems/pull-remote-git-branch) - [Checkout](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Checkout Commit](https://www.gitkraken.com/learn/git/problems/git-checkout-commit) - [How do you checkout a Git tag?](https://www.gitkraken.com/learn/git/problems/git-checkout-tag) - [Cherry Pick](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Can you cherry pick from another repository in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-from-another-repository) - [Can you cherry pick multiple commits in Git?](https://www.gitkraken.com/learn/git/problems/cherry-pick-multiple-commits) - [Clone](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git clone a branch?](https://www.gitkraken.com/learn/git/problems/git-clone-branch) - [Commit](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you revert a commit in Git?](https://www.gitkraken.com/learn/git/problems/revert-git-commit) - [How do you amend a Git commit message?](https://www.gitkraken.com/learn/git/problems/git-commit-amend) - [How do you undo a Git commit?](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Merge](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you undo a Git merge?](https://www.gitkraken.com/learn/git/problems/undo-git-merge) - [Pull](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [Git Pull vs Fetch](https://www.gitkraken.com/learn/git/problems/git-pull-vs-fetch) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you Git pull force?](https://www.gitkraken.com/learn/git/problems/git-pull-force) - [How do you Git pull rebase?](https://www.gitkraken.com/learn/git/problems/git-pull-rebase) - [Push](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you Git push a tag?](https://www.gitkraken.com/learn/git/problems/git-push-tag) - [How do you Git push to a remote branch?](https://www.gitkraken.com/learn/git/problems/git-push-to-remote-branch) - [How do you force a Git push?](https://www.gitkraken.com/learn/git/problems/git-push-force) - [Rebase](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you perform an interactive rebase?](https://www.gitkraken.com/learn/git/problems/git-interactive-rebase) - [When to Git rebase vs merge?](https://www.gitkraken.com/learn/git/problems/git-rebase-vs-merge) - [How do you Git rebase a branch?](https://www.gitkraken.com/learn/git/problems/git-rebase-branch) - [SSH](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [GitHub](https://www.gitkraken.com/learn/git/problems/undo-git-commit) - [How do you delete a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-delete-repository) - [How do you create a GitHub pull request?](https://www.gitkraken.com/learn/git/problems/github-pull-requests) - [How do you add an SSH key to GitHub?](https://www.gitkraken.com/learn/git/problems/github-add-ssh-key) - [How do you fork a GitHub repository?](https://www.gitkraken.com/learn/git/problems/github-how-to-fork) # Undo Git Commit Even for the more experienced and diligent developers, mistakes happen when working with Git repositories. So what is the best step to take after you make a mistake in Git? Well, that depends. Depending on the scenario at hand, the best process for fixing your mistake might be to undo it all together. But beware: if you aren’t careful, attempting to fix a mistake the wrong way can cause you to lose important work, introduce code conflicts, and more. Thankfully, Git does offer some tools to help you undo mistakes specifically that are introduced with a new commit. Let’s look at all of the options you have for how to undo a Git commit in [GitKraken Git client](https://www.gitkraken.com/git-client), first in the GUI before looking at the process in the [CLI](https://www.gitkraken.com/cli). “Thank you @GitKraken for the undo feature, accidentally discarded all my changes but now they are back again 😃” – [@offset1337](https://twitter.com/offset1337/status/1107615811181658118) [Download GitKraken Desktop Free](https://www.gitkraken.com/download) Available on: [Download GitKraken Windows / Mac / Linux](https://www.gitkraken.com/download) ## **Do you need to undo a Git commit?** Before you begin the process of undoing a Git commit, you should make sure you actually want to *undo* something, rather than just fix or edit something. If you do need to edit your last commit, you can [amend the Git commit](https://www.gitkraken.com/learn/git/problems/git-commit-amend) instead. Amending a Git commit allows you to correct the previous commit message and add more changes to it. ## **Undo Last Git Commit** Let’s say that you’ve committed the wrong files, but you haven’t pushed your code changes to your [Git remote](https://www.gitkraken.com/learn/git/git-remote) yet, so you need to Git undo the local commit. How can you undo the last commit, or group of commits, from your local Git repository? ## **Undo Last Git Commit in GitKraken** When you make a mistake in GitKraken, the solution is just one-click away. If you make a mistake with your last commit and wish to undo the last Git commit before you push, you can simply click the magical `Undo` button at the toolbar at the top of the UI. ![undo-git-commit-gitkraken-undo-buttonitt](https://www.gitkraken.com/wp-content/uploads/2021/07/undo-2-e1626900710447-1024x612.png) Better yet, if you realize that you actually did not want to undo your last Git commit, you can click the `Redo` button to undo your undo. It’s important to remember, using the `Undo` button will work to undo a commit if you haven’t performed any other actions, but let’s say you’ve [created a Git branch](https://www.gitkraken.com/learn/git/problems/create-git-branch), for example. In this case, using the `Undo` button would undo the branch, not the commit. To undo a Git commit after you’ve performed another action in GitKraken, you will have to use the Git reset feature. Simply right-click on the commit from the central graph and select `Reset` -\> `Soft` to keep all of the changes, or `Reset` -\> `Hard` to discard the changes, if you’re sure you won’t need them again in the future. ![undo git commit git reset hard soft gitkraken](https://www.gitkraken.com/wp-content/uploads/2021/10/undo-git-commit-git-reset-gitkraken-1024x328.png) Whether you prefer to use a GUI or CLI, GitKraken makes undoing actions, like undoing your last commit, easy and safe so you can have more confidence in your workflow. [Download GitKraken Client Free](https://www.gitkraken.com/download) [Download GitKraken Windows / Mac / Linux](https://www.gitkraken.com/download) ## **Undo Last Git Commit in the GitKraken CLI** Now, let’s go over the process of how to undo your last Git commit using the [GitKraken CLI](https://www.gitkraken.com/cli). ## **Git Reset** Compared to [reverting a Git commit](https://www.gitkraken.com/learn/git/problems/revert-git-commit), Git reset allows you to move back in time to a particular commit, and reset your active position to a selected commit. With Git reset, you have two options: you can Git reset “soft” or Git reset “hard”. ## **How do you Git undo your last commit and keep changes?** If you want to undo your last Git commit but keep the changes, a soft Git reset will do the trick. Using the `--soft` flag will ensure that the changes in undone revisions are preserved. You can find these changes as uncommitted local modifications in your working copy after you perform a soft Git reset. If you’re using the GitKraken CLI, you can simply type: `$  git reset --soft HEAD~1` Git reset should be used with care. Let’s say, for example, that you travel back in time to a commit far back in your history; all of the commits you passed along the way may now end up in a dangling state where they exist, but nothing references them. And if you perform a “hard” reset, you risk losing work that wasn’t backed up properly. You should only perform a hard Git reset if you are positive you don’t need those changes anymore. `$  git reset --hard HEAD~1` As a Git best practice, you should always avoid doing anything that requires a force push, which will rewrite the history of your main branch(es). Get ready to revolutionize your workflow with Git by having the power of a GUI and CLI at your fingertips, enabling you to choose the best tool for each action according to your preference. [Download GitKraken Client Free](https://www.gitkraken.com/download) [Download GitKraken Windows / Mac / Linux](https://www.gitkraken.com/download) ### Additional Resources [![](https://www.gitkraken.com/wp-content/uploads/2026/01/AI-Appreciation-Day-Blog-Hero-2-300x169.png)](https://www.gitkraken.com/blog/how-gitkrakens-ai-powered-commit-composer-eliminates-git-cleanup-headaches) ##### [How GitKraken’s AI-Powered Commit Composer Eliminates Git Cleanup Headaches](https://www.gitkraken.com/blog/how-gitkrakens-ai-powered-commit-composer-eliminates-git-cleanup-headaches) [![Learn Git](https://www.gitkraken.com/wp-content/uploads/2021/03/og-learn-git-1-300x158.png)](https://www.gitkraken.com/learn/git/git-add) ##### [Git Add](https://www.gitkraken.com/learn/git/git-add) [![](https://www.gitkraken.com/wp-content/uploads/2021/03/og-git-best-practices-300x158.png)](https://www.gitkraken.com/learn/git/best-practices/git-commit-message) ##### [Writing a Good Git Commit Message](https://www.gitkraken.com/learn/git/best-practices/git-commit-message) [![](https://www.gitkraken.com/wp-content/uploads/2021/03/og-git-problems-300x157.png)](https://www.gitkraken.com/learn/git/problems/revert-git-commit) ##### [How to Revert a Git Commit](https://www.gitkraken.com/learn/git/problems/revert-git-commit) [![](https://www.gitkraken.com/wp-content/uploads/2021/03/og-git-problems-300x157.png)](https://www.gitkraken.com/learn/git/problems/git-commit-amend) ##### [How do you amend a Git commit?](https://www.gitkraken.com/learn/git/problems/git-commit-amend) [![learn git branch concepts](https://www.gitkraken.com/wp-content/uploads/2021/03/og-learn-git-300x158.png)](https://www.gitkraken.com/learn/git/commit) ##### [Learn Git: Commit](https://www.gitkraken.com/learn/git/commit) #### Table of Contents Related Content ### [How GitKraken’s AI-Powered Commit Composer Eliminates Git Cleanup Headaches](https://www.gitkraken.com/blog/how-gitkrakens-ai-powered-commit-composer-eliminates-git-cleanup-headaches) [Keep Reading »](https://www.gitkraken.com/blog/how-gitkrakens-ai-powered-commit-composer-eliminates-git-cleanup-headaches) ### Make Git Easy: Visual, Powerful, AI-Assisted. [Download GitKraken Desktop Free](https://www.gitkraken.com/download) Available on: [Download GitKraken Windows / Mac / Linux](https://www.gitkraken.com/download) [Start Free GitKraken Pro Trial](https://gitkraken.dev/trial?source=marketing_page) ![](https://www.gitkraken.com/wp-content/uploads/2026/01/GK_commit-graph_glow-1-1024x762.png) ![](https://www.gitkraken.com/wp-content/uploads/2021/12/Union.svg) **Products** [Pricing](https://www.gitkraken.com/pricing) [Help Center](https://help.gitkraken.com/) [GitKraken AI](https://www.gitkraken.com/solutions/gitkraken-ai) [**GitKraken Desktop**](https://www.gitkraken.com/git-client) - [Login](https://gitkraken.dev/login?source=marketing_page) - [Documentation](https://help.gitkraken.com/gitkraken-client/gitkraken-client-home/) - [Release Notes](https://help.gitkraken.com/gitkraken-client/current/) - [Roadmap](https://www.gitkraken.com/git-client/roadmap) - [Feature Upvote](http://feedback.gitkraken.com/) - [Cheat Sheet](https://www.gitkraken.com/pdfs/gitkraken-git-gui-cheat-sheet) [**GitLens**](https://www.gitkraken.com/gitlens) - [Documentation](https://help.gitkraken.com/gitlens/gitlens-home/) - [GitLens for Cursor](https://www.gitkraken.com/gitlens/cursor) - [GitLens for Windsurf](https://www.gitkraken.com/gitlens/windsurf) - [GitLens for Trae](https://www.gitkraken.com/gitlens/trae) - [GitLens for Kiro](https://www.gitkraken.com/gitlens/kiro) [**GitKraken CLI**](https://www.gitkraken.com/cli) [**Git Integration for Jira**](https://www.gitkraken.com/git-integration-for-jira) - [Cloud Docs](https://help.gitkraken.com/git-integration-for-jira-cloud/git-integration-for-jira-home-gij-cloud/) - [Data Center/Server Docs](https://help.gitkraken.com/git-integration-for-jira-data-center/git-integration-for-jira-home-self-manged/) - [Security & Trust](https://trust.gitkraken.com/) **Community** [Referral Program](https://www.gitkraken.com/referral-program) [Learn Git Library](https://www.gitkraken.com/learn/git) [Git Commands Cheat Sheet](https://www.gitkraken.com/pdfs/git-basics-cheat-sheet) [Git Blog](https://www.gitkraken.com/blog) [GitKraken Labs](https://www.gitkraken.com/labs) [Git Conference](http://gitkon.com/) [Ambassador Program](https://www.gitkraken.com/ambassador) [Newsletter](https://www.gitkraken.com/newsletter) [Slack Community](https://www.gitkraken.com/join-slack-community) [GitKraken for Students](https://www.gitkraken.com/github-student-developer-pack-bundle) [Store](https://www.gitkraken.com/store) [Keif Gallery](https://www.gitkraken.com/keif-gallery) [Bug Bounty Program](https://www.gitkraken.com/bug-bounty-program) **Company** [Contact Us](https://www.gitkraken.com/contact) [About Us](https://www.gitkraken.com/about) [Careers](https://www.gitkraken.com/careers) [Customers](https://www.gitkraken.com/sample-customers) [Media](https://www.gitkraken.com/media) [News](https://www.gitkraken.com/media/news) [Awards](https://www.gitkraken.com/media/awards) [Events](https://www.gitkraken.com/media/events) [Press Releases](https://www.gitkraken.com/media/press) [Logos](https://www.gitkraken.com/media/press-releases#logos) [Privacy](https://www.gitkraken.com/privacy) [Trust Center](https://trust.gitkraken.com/) [Slack](https://www.gitkraken.com/join-slack-community) [Youtube](https://www.youtube.com/gitkraken) [Linkedin](https://www.linkedin.com/company/gitkraken) **© 2026 Axosoft, LLC DBA GitKraken** **Visual Studio Code is required to install GitLens.** Don’t have Visual Studio Code? [Get it now](https://code.visualstudio.com/download). [Continue to install GitLens](vscode:extension/eamodio.gitlens) #### Team Collaboration Services Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members **Launchpad** – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. **Code Suggest** – Real code suggestions anywhere in your project, as simple as in Google Docs. **Cloud Patches** – Speed up PR reviews by enabling early collaboration on work-in-progress. **Workspaces** – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. **DORA Insights** – Data-driven code insights to track & improve development velocity. **Security & Admin** – Easily set up SSO, manage access, & streamline IdP integrations. [![](https://www.gitkraken.com/wp-content/uploads/2024/05/Union.svg) Start Your Free Trial](https://gitkraken.dev/trial?redirect_uri=https://www.gitkraken.com/typ/trial-start-success&source=marketing_page) #### GitKraken Browser Extension Your bridge between apps [Track PRs](https://www.gitkraken.com/browser-extension#track-prs) – [View PRs in GitKraken or VS Code](https://www.gitkraken.com/browser-extension#view-prs) – [Work More Effectively with Repo Providers](https://www.gitkraken.com/browser-extension#work-more-effectively) [![](https://www.gitkraken.com/wp-content/uploads/2024/05/chrome-icon.svg)Add to Chrome](https://chrome.google.com/webstore/detail/gitkraken/egmopflbpgdjmmkeabegohajillnebco) [![](https://www.gitkraken.com/wp-content/uploads/2024/05/ff-icon.svg)Add to Firefox](https://addons.mozilla.org/en-US/firefox/addon/gitkraken-browser-extension/) [![](https://www.gitkraken.com/wp-content/uploads/2024/05/edge-icon.svg)Add to Microsoft Edge](https://microsoftedge.microsoft.com/addons/detail/gitkraken/eehliiniplilmbgcnghhaneefihofjnl) #### GitLens for VS Code Your IDE, Smarter with Git 40M+ INSTALLS [Navigate Git, Minimize Mistakes](https://www.gitkraken.com/gitlens#navigate-git) – [Unblock PR & Code Reviews](https://www.gitkraken.com/gitlens#unblock-pr) – [Manage Multiple Repos](https://www.gitkraken.com/gitlens#manage-multiple-repos) – [Code with Momentum](https://www.gitkraken.com/gitlens#code-momentum) [![](https://www.gitkraken.com/wp-content/uploads/2024/05/gitlens-btn-icon.svg) Install GitLens in VS Code](https://www.gitkraken.com/learn/git/problems/undo-git-commit#elementor-action%3Aaction%3Dpopup%3Aopen%26settings%3DeyJpZCI6IjY0OTciLCJ0b2dnbGUiOmZhbHNlfQ%3D%3D) #### GitKraken CLI Ultimate CLI for Git Collaboration [Bring PRs, WIPs & Issues to the Terminal](https://www.gitkraken.com/cli#bring-prs-to-terminal) – [Run Multi-Repo Commands](https://www.gitkraken.com/cli#run-multi-repo-commands) – [Manage Groups of Repos](https://www.gitkraken.com/cli#manage-groups-of-repos) – [Suggest Code Revisions](https://www.gitkraken.com/cli#suggest-code-revisions) ``` winget install gitkraken.cli ``` [Or download on GitHub](https://github.com/gitkraken/gk-cli/releases/latest) #### GitKraken.dev Your Command Center in the Browser [Track PRs & Issues](https://www.gitkraken.com/gitkraken-dev#track-prs) – [Suggest and Share Code Changes](https://www.gitkraken.com/gitkraken-dev#suggest-send-code-changes) – [Ramp Up New Devs Faster](https://www.gitkraken.com/gitkraken-dev#ramp-up-new-devs) – [Bring Your Team Together](https://www.gitkraken.com/gitkraken-dev#bring-your-team-together) – [Secure and Control Your Data](https://www.gitkraken.com/gitkraken-dev#secure-control-data) [Sign Into Your Account](https://gitkraken.dev/login?source=marketing_page) [Sign up for free](https://gitkraken.dev/register?source=marketing_page) #### GitKraken Desktop Simplify Git For Any OS [Visualize Git, Minimize Mistakes](https://www.gitkraken.com/git-client#visualize-git) – [Unblock PR & Code Reviews](https://www.gitkraken.com/git-client#unblock-pr) – [Manage Multiple Repos](https://www.gitkraken.com/git-client#manage-multiple-repos) – [Resolve Merge Conflicts with Ease](https://www.gitkraken.com/git-client#resolve-merge-conflicts) – [Ramp Up Devs Faster](https://www.gitkraken.com/git-client#ramp-up-new-devs) [Download GitKraken Desktop Free](https://www.gitkraken.com/download) Available on: [Download GitKraken Windows / Mac / Linux](https://www.gitkraken.com/download) [Start Free GitKraken Pro Trial](https://gitkraken.dev/trial?source=marketing_page)
Readable Markdown
Even for the more experienced and diligent developers, mistakes happen when working with Git repositories. So what is the best step to take after you make a mistake in Git? Well, that depends. Depending on the scenario at hand, the best process for fixing your mistake might be to undo it all together. But beware: if you aren’t careful, attempting to fix a mistake the wrong way can cause you to lose important work, introduce code conflicts, and more. Thankfully, Git does offer some tools to help you undo mistakes specifically that are introduced with a new commit. Let’s look at all of the options you have for how to undo a Git commit in [GitKraken Git client](https://www.gitkraken.com/git-client), first in the GUI before looking at the process in the [CLI](https://www.gitkraken.com/cli). “Thank you @GitKraken for the undo feature, accidentally discarded all my changes but now they are back again 😃” – [@offset1337](https://twitter.com/offset1337/status/1107615811181658118) [Download GitKraken Desktop Free](https://www.gitkraken.com/download) Available on: ## **Do you need to undo a Git commit?** Before you begin the process of undoing a Git commit, you should make sure you actually want to *undo* something, rather than just fix or edit something. If you do need to edit your last commit, you can [amend the Git commit](https://www.gitkraken.com/learn/git/problems/git-commit-amend) instead. Amending a Git commit allows you to correct the previous commit message and add more changes to it. ## **Undo Last Git Commit** Let’s say that you’ve committed the wrong files, but you haven’t pushed your code changes to your [Git remote](https://www.gitkraken.com/learn/git/git-remote) yet, so you need to Git undo the local commit. How can you undo the last commit, or group of commits, from your local Git repository? ## **Undo Last Git Commit in GitKraken** When you make a mistake in GitKraken, the solution is just one-click away. If you make a mistake with your last commit and wish to undo the last Git commit before you push, you can simply click the magical `Undo` button at the toolbar at the top of the UI. ![undo-git-commit-gitkraken-undo-buttonitt](https://www.gitkraken.com/wp-content/uploads/2021/07/undo-2-e1626900710447-1024x612.png) Better yet, if you realize that you actually did not want to undo your last Git commit, you can click the `Redo` button to undo your undo. It’s important to remember, using the `Undo` button will work to undo a commit if you haven’t performed any other actions, but let’s say you’ve [created a Git branch](https://www.gitkraken.com/learn/git/problems/create-git-branch), for example. In this case, using the `Undo` button would undo the branch, not the commit. To undo a Git commit after you’ve performed another action in GitKraken, you will have to use the Git reset feature. Simply right-click on the commit from the central graph and select `Reset` -\> `Soft` to keep all of the changes, or `Reset` -\> `Hard` to discard the changes, if you’re sure you won’t need them again in the future. ![undo git commit git reset hard soft gitkraken](https://www.gitkraken.com/wp-content/uploads/2021/10/undo-git-commit-git-reset-gitkraken-1024x328.png) Whether you prefer to use a GUI or CLI, GitKraken makes undoing actions, like undoing your last commit, easy and safe so you can have more confidence in your workflow. [Download GitKraken Client Free](https://www.gitkraken.com/download) ## **Undo Last Git Commit in the GitKraken CLI** Now, let’s go over the process of how to undo your last Git commit using the [GitKraken CLI](https://www.gitkraken.com/cli). ## **Git Reset** Compared to [reverting a Git commit](https://www.gitkraken.com/learn/git/problems/revert-git-commit), Git reset allows you to move back in time to a particular commit, and reset your active position to a selected commit. With Git reset, you have two options: you can Git reset “soft” or Git reset “hard”. ## **How do you Git undo your last commit and keep changes?** If you want to undo your last Git commit but keep the changes, a soft Git reset will do the trick. Using the `--soft` flag will ensure that the changes in undone revisions are preserved. You can find these changes as uncommitted local modifications in your working copy after you perform a soft Git reset. If you’re using the GitKraken CLI, you can simply type: `$  git reset --soft HEAD~1` Git reset should be used with care. Let’s say, for example, that you travel back in time to a commit far back in your history; all of the commits you passed along the way may now end up in a dangling state where they exist, but nothing references them. And if you perform a “hard” reset, you risk losing work that wasn’t backed up properly. You should only perform a hard Git reset if you are positive you don’t need those changes anymore. `$  git reset --hard HEAD~1` As a Git best practice, you should always avoid doing anything that requires a force push, which will rewrite the history of your main branch(es). Get ready to revolutionize your workflow with Git by having the power of a GUI and CLI at your fingertips, enabling you to choose the best tool for each action according to your preference. [Download GitKraken Client Free](https://www.gitkraken.com/download)
Shard29 (laksa)
Root Hash997466358027218229
Unparsed URLcom,gitkraken!www,/learn/git/problems/undo-git-commit s443