mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
git-undo now includes -h|--hard option.
-h option allows you to undo the last commit without keeping the changes in the local working directory. Use with care. Updated documentation to include new option.
This commit is contained in:
parent
515e94a0cd
commit
6459db39aa
32
bin/git-undo
32
bin/git-undo
|
|
@ -1,13 +1,27 @@
|
|||
#!/bin/sh
|
||||
|
||||
if test $# -eq 0; then
|
||||
git reset --soft HEAD~1
|
||||
git reset
|
||||
hard='no'
|
||||
digit=1
|
||||
|
||||
parseArgs () {
|
||||
for var in "$@"; do
|
||||
if [ "$var" = "--hard" -o "$var" = "-h" ]; then
|
||||
hard='yes';
|
||||
elif `echo $var | grep -q [^[:digit:]]`; then
|
||||
echo "You entered an invalid option. Valid options are [--hard|-h] [commitcount]." 1>&2
|
||||
exit 1;
|
||||
else
|
||||
digit=$var
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
parseArgs $@
|
||||
|
||||
if [ "$hard" = "yes" ]; then
|
||||
git reset --hard HEAD~$digit
|
||||
else
|
||||
if `echo $1 | grep -q [^[:digit:]]`; then
|
||||
echo "$1 is not a number" 1>&2
|
||||
else
|
||||
git reset --soft HEAD~$1
|
||||
git reset
|
||||
fi
|
||||
git reset --soft HEAD~$digit
|
||||
git reset
|
||||
fi
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,13 @@
|
|||
.\" generated with Ronn/v0.7.3
|
||||
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
||||
.
|
||||
.TH "GIT\-UNDO" "1" "March 2011" "" "Git Extras"
|
||||
.TH "GIT\-UNDO" "1" "June 2012" "" ""
|
||||
.
|
||||
.SH "NAME"
|
||||
\fBgit\-undo\fR \- Remove latest commits
|
||||
.
|
||||
.SH "SYNOPSIS"
|
||||
\fBgit\-undo\fR [<commitcount>]
|
||||
\fBgit\-undo\fR [<commitcount>] [\-\-hard|\-h]
|
||||
.
|
||||
.SH "DESCRIPTION"
|
||||
Removes the latest commits\.
|
||||
|
|
@ -18,6 +18,12 @@ Removes the latest commits\.
|
|||
.P
|
||||
Number of commits to remove\. Defaults to \fI1\fR, thus remove the latest commit\.
|
||||
.
|
||||
.P
|
||||
\-\-hard or \-h
|
||||
.
|
||||
.P
|
||||
This option wipes your commit(s), so that your changes cannot be recovered\. Use with care\.
|
||||
.
|
||||
.SH "EXAMPLES"
|
||||
Removes the latest commit\.
|
||||
.
|
||||
|
|
|
|||
|
|
@ -61,11 +61,11 @@
|
|||
<a href="#AUTHOR">AUTHOR</a>
|
||||
<a href="#REPORTING-BUGS">REPORTING BUGS</a>
|
||||
<a href="#SEE-ALSO">SEE ALSO</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<ol class='man-decor man-head man head'>
|
||||
<li class='tl'>git-undo(1)</li>
|
||||
<li class='tc'>Git Extras</li>
|
||||
<li class='tc'></li>
|
||||
<li class='tr'>git-undo(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
@ -76,7 +76,7 @@
|
|||
|
||||
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
||||
|
||||
<p><code>git-undo</code> [<commitcount>]</p>
|
||||
<p><code>git-undo</code> [<commitcount>] [--hard|-h]</p>
|
||||
|
||||
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
||||
|
||||
|
|
@ -88,6 +88,10 @@
|
|||
|
||||
<p> Number of commits to remove. Defaults to <em>1</em>, thus remove the latest commit.</p>
|
||||
|
||||
<p> --hard or -h</p>
|
||||
|
||||
<p> This option wipes your commit(s), so that your changes cannot be recovered. Use with care.</p>
|
||||
|
||||
<h2 id="EXAMPLES">EXAMPLES</h2>
|
||||
|
||||
<p> Removes the latest commit.</p>
|
||||
|
|
@ -102,20 +106,20 @@
|
|||
|
||||
<h2 id="AUTHOR">AUTHOR</h2>
|
||||
|
||||
<p>Written by Kenneth Reitz <<a href="mailto:me@kennethreitz.com" data-bare-link="true">me@kennethreitz.com</a>></p>
|
||||
<p>Written by Kenneth Reitz <<a data-bare-link="true" href="mailto:me@kennethreitz.com">me@kennethreitz.com</a>></p>
|
||||
|
||||
<h2 id="REPORTING-BUGS">REPORTING BUGS</h2>
|
||||
|
||||
<p><<a href="http://github.com/visionmedia/git-extras/issues" data-bare-link="true">http://github.com/visionmedia/git-extras/issues</a>></p>
|
||||
<p><<a data-bare-link="true" href="http://github.com/visionmedia/git-extras/issues">http://github.com/visionmedia/git-extras/issues</a>></p>
|
||||
|
||||
<h2 id="SEE-ALSO">SEE ALSO</h2>
|
||||
|
||||
<p><<a href="http://github.com/visionmedia/git-extras" data-bare-link="true">http://github.com/visionmedia/git-extras</a>></p>
|
||||
<p><<a data-bare-link="true" href="http://github.com/visionmedia/git-extras">http://github.com/visionmedia/git-extras</a>></p>
|
||||
|
||||
|
||||
<ol class='man-decor man-foot man foot'>
|
||||
<li class='tl'></li>
|
||||
<li class='tc'>March 2011</li>
|
||||
<li class='tc'>June 2012</li>
|
||||
<li class='tr'>git-undo(1)</li>
|
||||
</ol>
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@ git-undo(1) -- Remove latest commits
|
|||
|
||||
## SYNOPSIS
|
||||
|
||||
`git-undo` [<commitcount>]
|
||||
`git-undo` [<commitcount>] [--hard|-h]
|
||||
|
||||
## DESCRIPTION
|
||||
|
||||
|
|
@ -15,6 +15,10 @@ git-undo(1) -- Remove latest commits
|
|||
|
||||
Number of commits to remove. Defaults to *1*, thus remove the latest commit.
|
||||
|
||||
--hard or -h
|
||||
|
||||
This option wipes your commit(s), so that your changes cannot be recovered. Use with care.
|
||||
|
||||
## EXAMPLES
|
||||
|
||||
Removes the latest commit.
|
||||
|
|
|
|||
Loading…
Reference in a new issue