dotfiles/.local/bin/git-rmbranch
xerus2000 e2faef48d6 config/git: move branching aliases to bins and update logging
- disabled git reset --hard
- improved lno to conditionally use newlines
- get git-dir appropriately
2020-11-14 02:05:51 +01:00

7 lines
413 B
Bash
Executable file

#!/bin/sh
# Removes the given branch locally and remotely.
# With no argument it switches to the default branch and deletes the current branch.
branch=${1:-$(git curbranch)}
git push -d $(git rev-parse --abbrev-ref $branch@{push} | sed 's/\// /' || echo origin $branch)
test $1 || git checkout main || git checkout master || git checkout $(cat .git/refs/remotes/origin/HEAD | cut -d'/' -f4)
git branch -D $branch