Say you have a branch on your origin that has a ridiculously long name…
$> git branch -a
* master
origin/master
origin/branch-with-a-ridiculously-long-name
And when you work on that branch locally, you want to give it a less ridiculous name, like bob.
$> git checkout origin/branch-with-a-ridiculously-long-name
$> git checkout -b bob
$> git branch --set-upstream bob origin/branch-with-a-ridiculously-long-name
When it comes time to push, what can you do such that if you run:
$> git checkout bob
$> git push
then any local changes on “bob” will be sent to the “branch-with-a-ridiculously-long-name”, and won’t create a new branch on origin called “bob”?
I’m effectively after a way of making git push implicitly expand in to git push origin bob:branch-with-a-ridiculously-long-name.
I think setting git config push.default upstream goes part of the way, but I’m not sure how to deal with the fact that the local branch’s name differs from the remote.
If you set
push.defaulttoupstream(ortrackingin versions of git before 1.7.4.2), that should do exactly what you want when you run:… or:
The
git branch --set-upstreamcommand that you ran, in combination with the config setting, should make that work.I wrote a post about this unfortunate asymmetry between git push and git pull.