diff --git a/Commands.md b/Commands.md index d7e8f0f..9e01de1 100644 --- a/Commands.md +++ b/Commands.md @@ -1,4 +1,5 @@ + - [`git abort`](#git-abort) - [`git alias`](#git-alias) - [`git archive-file`](#git-archive-file) - [`git authors`](#git-authors) @@ -1539,3 +1540,7 @@ total 308 -rwxr-xr-x 1 vt vt 18561 Sep 5 2019 git-changelog -rwxr-xr-x 1 vt vt 215 Nov 19 2016 git-clear ``` + +## git abort + +Abort current rebase, merge or cherry-pick, without the need to find exact command in history. diff --git a/bin/git-abort b/bin/git-abort new file mode 100755 index 0000000..abc3ed7 --- /dev/null +++ b/bin/git-abort @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +gitdir="$(git rev-parse --git-dir)" || exit +opfound= +fcnt= +for i in cherry-pick merge rebase; do + f=${i^^} + f=${f/-/_} + test -f "${gitdir}/${f}_HEAD" && fcnt=1$fcnt && opfound=$i +done + +if [ "${fcnt}" != 1 ]; then + echo "I don't know what to abort" >&2 + exit 1 +fi + +git "${opfound}" --abort diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index ea7cba9..8f0d713 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -335,6 +335,7 @@ zstyle -g existing_user_commands ':completion:*:*:git:*' user-commands zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ alias:'define, search and show aliases' \ + abort:'abort current merge, rebase, or cherry-pick process' \ archive-file:'export the current head of the git repository to an archive' \ authors:'generate authors report' \ browse:'open repo website in browser' \ diff --git a/man/git-abort.1 b/man/git-abort.1 new file mode 100644 index 0000000..a4704c0 --- /dev/null +++ b/man/git-abort.1 @@ -0,0 +1,19 @@ +.\" generated with Ronn-NG/v0.8.0 +.\" http://github.com/apjanke/ronn-ng/tree/0.8.0 +.TH "GIT\-ABORT" "1" "August 2020" "" "Git Extras" +.SH "NAME" +\fBgit\-abort\fR \- Abort current git operation +.SH "SYNOPSIS" +\fBgit\-abort\fR +.SH "DESCRIPTION" +Abort current git rebase, merge or cherry\-pick process\. +.SH "OPTIONS" +There are no options, it just aborts current operation\. +.SH "EXAMPLES" +\fBgit\-abort\fR +.SH "AUTHOR" +Written by Przemek Kitszel <\fI\%mailto:pkitszel@gmail\.com\fR> +.SH "REPORTING BUGS" +<\fI\%https://github\.com/tj/git\-extras/issues\fR> +.SH "SEE ALSO" +<\fI\%https://github\.com/tj/git\-extras\fR> diff --git a/man/git-abort.html b/man/git-abort.html new file mode 100644 index 0000000..697537a --- /dev/null +++ b/man/git-abort.html @@ -0,0 +1,114 @@ + + +
+ + +
+ git-abort - Abort current git operation
+
git-abort
Abort current git rebase, merge or cherry-pick process.
+ +There are no options, it just aborts current operation.
+ + git-abort
Written by Przemek Kitszel <pkitszel@gmail.com>
+ +<https://github.com/tj/git-extras/issues>
+ +<https://github.com/tj/git-extras>
+ +