Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make git undo -s restore the staging area #723

Merged
merged 1 commit into from
Mar 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions AUTHORS
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ Patches and Suggestions
- Nick Campbell
- Nick Payne
- Niklas Fiekas
- Peter Bittner
- Prayag Verma
- R. Martinho Fernandes
- Raphael Fleischlin
Expand Down
8 changes: 4 additions & 4 deletions bin/git-undo
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ EOL
;;
--hard)
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
git reset --hard HEAD$back && exit 0;
git reset --hard HEAD$back
;;
-s|--soft)
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
git reset --soft HEAD$back
;;
*)
test $1 -gt 1 > /dev/null 2>&1 && back="~$1"
git reset --soft HEAD$back
git reset
;;
esac

git reset --soft HEAD$back
git reset
17 changes: 15 additions & 2 deletions man/git-undo.1
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
.\" generated with Ronn/v0.7.3
.\" http://github.com/rtomayko/ronn/tree/0.7.3
.
.TH "GIT\-UNDO" "1" "April 2018" "" "Git Extras"
.TH "GIT\-UNDO" "1" "June 2018" "" "Git Extras"
.
.SH "NAME"
\fBgit\-undo\fR \- Remove latest commits
Expand All @@ -16,7 +16,7 @@ Removes the latest commits\.
\-\-soft or \-s
.
.P
This is the default, only rolls back the commit but changes remain un\-staged\.
Rolls back the commit(s) but leaves the changes in the staging area\.
.
.P
\-\-hard or \-h
Expand Down Expand Up @@ -44,6 +44,19 @@ $ git undo
.IP "" 0
.
.P
Removes the latest commit, restoring the staging area\.
.
.IP "" 4
.
.nf

$ git undo \-s
.
.fi
.
.IP "" 0
.
.P
Remove the latest 3 commits:
.
.IP "" 4
Expand Down
11 changes: 8 additions & 3 deletions man/git-undo.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion man/git-undo.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ git-undo(1) -- Remove latest commits

--soft or -s

This is the default, only rolls back the commit but changes remain un-staged.
Rolls back the commit(s) but leaves the changes in the staging area.

--hard or -h

Expand All @@ -30,6 +30,10 @@ git-undo(1) -- Remove latest commits

$ git undo

Removes the latest commit, restoring the staging area.

$ git undo -s

Remove the latest 3 commits:

$ git undo 3
Expand Down