Skip to content

Commit

Permalink
git undo
Browse files Browse the repository at this point in the history
  • Loading branch information
szunyog committed May 22, 2015
1 parent a2cc487 commit 62d28c9
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions _posts/2015-05-01-git-undo-commit.md
@@ -0,0 +1,25 @@
---
layout: post
title: "Undo a commit and redo"
date: 2015-05-01 10:31:49
categories: git
---

When you need to undo your last git commit...

{% highlight bash %}

$ git commit ... (1)
$ git reset --soft HEAD~1 (2)
<< make corrections >> (3)
$ git add .... (4)
$ git commit -c ORIG_HEAD (5)

{% endhighlight %}

1. The last commit what should be undone.
2. Reset to the parent "commit", "soft" option does not touch the index file or the working tree at all, but resets the head to <commit>,</commit>.
3. Make corrections to working tree files.
4. Stage changes for commit.
5. Commit the changes.

0 comments on commit 62d28c9

Please sign in to comment.