Configure git to create remote branch with local branch names
tl;dr: use
$ git config --global push.default current
to have git create remote branch with the local branch name.
At one time, I configured git to create remote branches with the local branch name so when making a new remote branch is as easy as:
Except I forgot what the configuration was! I (and my colleagues) encountered this situation:
and the usual solution would be:
- take hand off home row
- copy the command:
git push --set-upstream origin test
that git automatically generated (“how convenient!”) - paste the command
- get my keys onto home row
- press enter
- type:
git push
That’s six steps, four if your hand was not on home row to begin with, but manual steps that aren’t really automatable.
When I started looking for what I did to configure git push -u
to
basically automate the above six steps, I could not… it’s
difficult because results focus on just working with remote branches…
Until today.
The key configuration for git to automate the six steps when pushing a new local branch and have it created on the remote server is:
All this does is push the current branch only. No simple or matching, just the current.
With this configuration, pushing a new local branch to github becomes:
and now I can move my hands off home row (and keep them off!) to open a browser to github to create a pull request. :-)