dotfiles/bin/executable_git-promote
Oliver Weyhmueller 4ec771a1c7
Update
* .gitconfig
* .chezmoi.yaml.tmpl
* .tmux.conf
* .vim
* .ssh
* .p10k.zsh
2022-01-30 20:56:16 +01:00

18 lines
No EOL
712 B
Bash

#!/bin/sh
#
# Promotes a local topic branch to a remote tracking branch of the same name,
# by pushing and then setting up the git config
#
# Thanks to ENTP:
# http://hoth.entp.com/2008/11/10/improving-my-git-workflow
curr_branch=$(git symbolic-ref -q HEAD | sed -e 's|^refs/heads/||')
remote_branch=$(git branch -r | grep "origin/${curr_branch}")
[ -z "${remote_branch}" ] && ( git push origin "${curr_branch}" )
origin=$(git config --get "branch.${curr_branch}.remote")
[ -z "${origin}" ] && ( git config --add "branch.${curr_branch}.remote" origin )
merge=$(git config --get "branch.${curr_branch}.merge")
[ -z "${merge}" ] && ( git config --add "branch.${curr_branch}.merge" "refs/heads/${curr_branch}" )