Skip to content

Instantly share code, notes, and snippets.

@taq
Created October 11, 2016 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taq/1ef38725c39c041f59701f29a83c7fa3 to your computer and use it in GitHub Desktop.
Save taq/1ef38725c39c041f59701f29a83c7fa3 to your computer and use it in GitHub Desktop.
Git alias to create a new remote branch based on the current branch
Just insert on .gitconfig:
nrb = "!f() { git push -u origin $(git rev-parse --abbrev-ref HEAD):$1; }; f"
And then, when on a local branch and want to push to a new remote branch called, say, 'test':
$ git nbr test
Total 0 (delta 0), reused 0 (delta 0)
To <your remote here>
* [new branch] work -> test
Branch work set up to track remote branch test from origin.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment