Skip to content

Instantly share code, notes, and snippets.

@thekarel
Forked from sstephenson/git-track
Last active August 29, 2015 13:56
Show Gist options
  • Save thekarel/9294013 to your computer and use it in GitHub Desktop.
Save thekarel/9294013 to your computer and use it in GitHub Desktop.
Track the branch with the same name as the current on origin
#!/bin/sh
# Track the branch with the same name as the current on origin
# To set up an alias `git track`, run
#
# git config --global --add alias.track '!git-track'
#
# (via https://gist.github.com/graysky/29079/)
branch=$(git describe --contains --all HEAD)
echo "OK to run?"
echo " "
echo " git config branch.$branch.remote origin"
echo " git config branch.$branch.merge refs/heads/$branch"
echo " "
echo "Enter to run, ctrl-c to cancel"
read x
git config branch.$branch.remote origin
git config branch.$branch.merge refs/heads/$branch
echo "tracking origin/$branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment