zsh,git: Add git-make-fork

This commit is contained in:
2022-10-17 17:28:31 +02:00
parent bc0affc832
commit e15fc71054
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
#!/usr/bin/env zsh
emulate -L zsh -o err_return
local url branch
# Make sure we're in a repo
git rev-parse
git remote rename origin upstream
# Assume that the fork is named equally
url="$(git remote get-url upstream)"
git remote add origin "git@github.com:druckdev/${url:t}"
git fetch origin
# Change remote tracking branch
if branch="$(git symbolic-ref HEAD 2>/dev/null)"; then
git branch -u origin/"${branch#refs/heads/}"
fi