mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-undo: add confirmation when -h is specified
This commit is contained in:
parent
8216e6bbbc
commit
16591d3788
20
bin/git-undo
20
bin/git-undo
|
|
@ -3,7 +3,25 @@
|
|||
back="^"
|
||||
|
||||
case "$1" in
|
||||
-h|--hard)
|
||||
-h)
|
||||
cat << EOL
|
||||
This will erase any changes since your last commit.
|
||||
If you want to get help info, run "git undo --help" instead.
|
||||
Do you want to continue? [yN]"
|
||||
EOL
|
||||
read -r res
|
||||
case "${res}" in
|
||||
"Y" | "y")
|
||||
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
|
||||
git reset --hard HEAD$back
|
||||
exit $?
|
||||
;;
|
||||
* )
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
--hard)
|
||||
test $2 -gt 1 > /dev/null 2>&1 && back="~$2"
|
||||
git reset --hard HEAD$back && exit 0;
|
||||
;;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-UNDO" "1" "December 2015" "" ""
|
||||
.TH "GIT\-UNDO" "1" "February 2018" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-undo\fR \- Remove latest commits
|
||||
|
|
@ -22,7 +22,7 @@ This is the default, only rolls back the commit but changes remain un\-staged\.
|
|||
\-\-hard or \-h
|
||||
.
|
||||
.P
|
||||
This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\.
|
||||
This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\. To avoid being confused with \fB\-\-help\fR, there will be a confirmation when \fB\-h\fR is specified\.
|
||||
.
|
||||
.P
|
||||
<commitcount>
|
||||
|
|
|
|||
|
|
@ -90,7 +90,8 @@
|
|||
|
||||
<p> --hard or -h</p>
|
||||
|
||||
<p> This option wipes your commit(s), so that your changes cannot be recovered. Use with care.</p>
|
||||
<p> This option wipes your commit(s), so that your changes cannot be recovered. Use with care.
|
||||
To avoid being confused with <code>--help</code>, there will be a confirmation when <code>-h</code> is specified.</p>
|
||||
|
||||
<p> <commitcount></p>
|
||||
|
||||
|
|
@ -110,7 +111,7 @@
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Kenneth Reitz <<a href="mailto:me@kennethreitz.com" data-bare-link="true">me@kennethreitz.com</a>> and Nick Lombard <<a href="mailto:github@jigsoft.co.za" data-bare-link="true">github@jigsoft.co.za</a>></p>
|
||||
<p>Written by Kenneth Reitz <<a href="mailto:me@kennethreitz.com" data-bare-link="true">me@kennethreitz.com</a>> and Nick Lombard <<a href="mailto:github@jigsoft.co.za" data-bare-link="true">github@jigsoft.co.za</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
|
|
@ -123,7 +124,7 @@
|
|||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>December 2015</li>
|
||||
<li class='tc'>February 2018</li>
|
||||
<li class='tr'>git-undo(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ git-undo(1) -- Remove latest commits
|
|||
--hard or -h
|
||||
|
||||
This option wipes your commit(s), so that your changes cannot be recovered. Use with care.
|
||||
To avoid being confused with `--help`, there will be a confirmation when `-h` is specified.
|
||||
|
||||
<commitcount>
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue