Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. | ||
|