Files
dotfiles/.config/zsh/autoload/git/git-make-fork
Julian Prein 234f452434 git:make-fork: Add call to git-https-and-ssh
When setting up the remotes the fetch url can use https since the fork
will be public anyways. This delays a prompt for the ssh key until it is
really necessary.
2024-03-24 13:46:42 +01:00

22 lines
452 B
Bash
Executable File

#!/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 https-and-ssh
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