Skip to content

Instantly share code, notes, and snippets.

@zenazn
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zenazn/10755890 to your computer and use it in GitHub Desktop.
Save zenazn/10755890 to your computer and use it in GitHub Desktop.
#!/bin/bash
if [ "$#" -gt 1 -o -z "$1" ]; then
echo "Usage: $0 new-branch"
exit 1
fi
current_branch=$(git rev-parse --abbrev-ref HEAD)
new_branch=$1
git checkout -b "$new_branch"
git config --null --get-regexp "^branch\.${current_branch}\..*" | (
while read -r conf_var; do
new_var="branch.$new_branch.${conf_var#branch.$current_branch.}"
read -r -d '' value
git config --add "$new_var" "$value"
done
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment