Skip to content

Instantly share code, notes, and snippets.

@githubnando
Last active August 18, 2017 20:48
Show Gist options
  • Save githubnando/a68ff19725e984d22d29a58c5f4c6dc4 to your computer and use it in GitHub Desktop.
Save githubnando/a68ff19725e984d22d29a58c5f4c6dc4 to your computer and use it in GitHub Desktop.
Alias for automatically setup tracking for origin in new branches and other useful git commands
# Automatically setup remote tracking for new branches

$ git config --global push.default current



# Make local repository current branch exactly like remote

$ currentBranch=git rev-parse --abbrev-ref HEAD
$ git fetch && git reset --hard origin/$currentBranch && git pull origin $currentBranch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment