From 0ccea4da66dc4cae98b640e4ad906f429e3a353b Mon Sep 17 00:00:00 2001 From: Erich Eckner Date: Sat, 8 Jan 2022 11:19:48 +0100 Subject: add some useful git commands --- git-fzf | 23 +++++++++++++++++++++++ git-merge-diff | 11 +++++++++++ git-push-first | 11 +++++++++++ 3 files changed, 45 insertions(+) create mode 100755 git-fzf create mode 100755 git-merge-diff create mode 100755 git-push-first diff --git a/git-fzf b/git-fzf new file mode 100755 index 0000000..9ce46e7 --- /dev/null +++ b/git-fzf @@ -0,0 +1,23 @@ +#!/bin/bash + +if [ "$1" = '--local' ] || [ "$1" = '-l' ]; then + shift + git_options='' + sed_prefix='' +else + git_options='--remote' + sed_prefix='origin/' +fi + +git branch ${git_options} 2>/dev/null \ +| sed ' + s@^..'"${sed_prefix}"'@@ + t + d +' \ +| fzf \ +| if [ "$#" -gt 0 ]; then + xargs -r git "$@" +else + cat +fi diff --git a/git-merge-diff b/git-merge-diff new file mode 100755 index 0000000..ad885de --- /dev/null +++ b/git-merge-diff @@ -0,0 +1,11 @@ +#!/bin/bash + +up="$1" +shift +[ $# -gt 0 ] \ +&& [ -n "${1%%--*}" ] \ +&& down="$1" \ +&& shift \ +|| down=HEAD + +git diff "$(git merge-base "$up" "$down")" "$down" "$@" diff --git a/git-push-first b/git-push-first new file mode 100755 index 0000000..26e50f4 --- /dev/null +++ b/git-push-first @@ -0,0 +1,11 @@ +#!/bin/bash + +eval "$( + git push 2>&1 \ + | sed ' + $d + ' \ + | sed -n ' + $p + ' +)" -- cgit v1.2.3-70-g09d2