Last active
August 29, 2015 13:59
-
-
Save zenazn/10755890 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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