Here's my usual workflow:
- create new a branch:
git checkout -b foo
- commit some stuff
- do a push:
git push
- get angry that push does not work (no upstream set)
- reach to mouse to highlight git's recommended command (still angry)
- push with setting upstream:
git push --set-upstream origin foo
(anger subsides)
Instead of 4. to 6., I would like to do some work when creating the new branch locally (without necessarily making my branch public yet, so no pushing) that kills steps 4. through 6. Is that possible?
Ideally something like git checkout -b foo -t origin
, which informs git that I plan to track a branch of the same name in origin
.
What I Tried
git checkout -b foo --set-upstream origin foo
~> error: unknown option 'set-upstream'
git checkout --track origin/foo
~> fatal: Cannot update paths and switch to branch 'foo' at the same time.
git checkout -b foo --track origin/foo
~> fatal: Cannot update paths and switch to branch 'foo' at the same time
git checkout -b foo --track
~> Branch foo set up to track local branch master.