hxtools/sdevel/git-track

17 lines
415 B
Bash
Executable File

#!/bin/bash
# SPDX-License-Identifier: MIT
#
# written up by Jan Engelhardt, 2008
current_branch=$(pcregrep -o '(?<=^ref: refs/heads/).+$' .git/HEAD);
if [[ -z "$current_branch" ]]; then
echo You do not seem to be on a branch >&2;
exit 1;
fi;
remote_name="${1%/*}";
remote_branch="${1#*/}";
git config "branch.$current_branch.remote" "$remote_name";
git config "branch.$current_branch.merge" "$remote_branch";