From 231010fa7935f5f467802072647bfa0a69018b96 Mon Sep 17 00:00:00 2001 From: William Hilton Date: Wed, 5 Jun 2019 10:41:12 -0400 Subject: [PATCH] feat: add 'g fff' --- README.md | 1 + bin/g | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/README.md b/README.md index 0c5f954..e940086 100644 --- a/README.md +++ b/README.md @@ -85,6 +85,7 @@ g fetch *branches* | Fetches and fast-forwards the specified branches g push | pushes to upstream. g remote | Interactive prompt to add a remote. g ff | git pull --ff-only +g fff | deletes the local branch and rechecks it out (useful when remote branch has been force-pushed and can't be fast-forwarded) \* To save your Github username where `get` can see it: `git config --global github.user your_user_name` diff --git a/bin/g b/bin/g index 70666d2..2736369 100755 --- a/bin/g +++ b/bin/g @@ -316,6 +316,17 @@ ff) git pull --ff-only ;; +fff) +# Get local branch name +local_branch=$(git rev-parse --abbrev-ref HEAD) +# Move HEAD pointer +git checkout HEAD~0 &>/dev/null +# Delete local branch +git branch -D "$local_branch" &>/dev/null +# Re-checkout the local branch +git checkout "$local_branch" +;; + ignore) GIT_ROOT=$(git_root) CWD=$(pwd)