Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
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