Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions config/fish/functions.fish
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,19 @@ function cheat --description "help <field> <topic>"
curl "cht.sh/$argv[1]/$args"
end

# update master and create a branch with value: $1
# update the default branch and create a fresh branch with value: $1
function gitissue
if test -z "$argv[1]"
echo "usage: gitissue <branch-name>"
return 1
end
# Detect the remote's default branch instead of assuming `master`,
# so this works on repos that use `main` (or anything else).
set -l default (git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null | string replace 'origin/' '')
if test -z "$default"
echo "Could not determine origin's default branch; run 'git remote set-head origin -a' first."
return 1
end
# `git reset --hard` discards uncommitted work, so confirm first.
if not git diff --quiet; or not git diff --cached --quiet
read -P "Uncommitted changes will be DISCARDED. Continue? [y/N] " -n 1 reply
Expand All @@ -25,7 +32,7 @@ function gitissue
end
end
git reset --hard
git checkout master
git pull origin master
git checkout $default
git pull origin $default
git checkout -b $argv[1]
end
Loading