From 5a82e182fc50d100771444ee42a1cd222bcf445e Mon Sep 17 00:00:00 2001 From: xerus2000 <27jf@pm.me> Date: Tue, 16 Feb 2021 13:11:05 +0100 Subject: [PATCH] config/git: rework git-p --- .config/git/config | 4 +--- .local/bin/scripts/git-p | 2 ++ .local/bin/scripts/git-rmbranch | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) create mode 100755 .local/bin/scripts/git-p diff --git a/.config/git/config b/.config/git/config index 5a57931..703d8eb 100644 --- a/.config/git/config +++ b/.config/git/config @@ -136,12 +136,10 @@ # Change remote luu = !git pull upstream $(git curbranch) && git push --no-verify - p = push - pu = push -u pf = push --force-with-lease cap = !git commit --all --amend --no-edit && git push --force-with-lease -[includeIf "gitdir:~/.config/yadm/repo.git"] +[includeIf "gitdir:yadm/repo.git"] path = "~/.config/yadm/gitconfig" [includeIf "gitdir:~/data/.git"] diff --git a/.local/bin/scripts/git-p b/.local/bin/scripts/git-p new file mode 100755 index 0000000..cd25769 --- /dev/null +++ b/.local/bin/scripts/git-p @@ -0,0 +1,2 @@ +#!/bin/sh +git rev-parse @{u} 2>/dev/null >/dev/null && git push || git push --set-upstream diff --git a/.local/bin/scripts/git-rmbranch b/.local/bin/scripts/git-rmbranch index 0ae089d..8423666 100755 --- a/.local/bin/scripts/git-rmbranch +++ b/.local/bin/scripts/git-rmbranch @@ -3,5 +3,5 @@ # With no argument it switches to the default branch and deletes the current branch. branch=${1:-$(git curbranch)} echo "${@:-$branch}" | sed 's/\([^ ]\+\)/\1@{push}/g' | xargs git rev-parse --abbrev-ref --revs-only | sed 's/\// /' | git push -d -test $1 || git checkout main || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -a) +test $1 || git checkout main 2>/dev/null || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -a) git branch -D "${@:-$branch}"