Reputation: 578
I know that in git you can use -
to refer to the previous branch you were on.
So for example, if I'm in the tester
branch and run git checkout master
, then decide I want to go back to tester
, I could run git checkout -
instead of git checkout tester
.
Is there some kind of syntactic sugar in git that allows me to reference the current branch I'm in?
So for instance, if I'm in master
and want to run git pull origin master
, could I run instead git pull origin {current branch sugar}
?
It's mostly just getting annoying having to specify the current branch name for common commands like push
, pull
, etc.
Upvotes: 1
Views: 130
Reputation: 1324063
Actually, a git pull
should be enough, provided your branch is set with an upstream branch
git branch -u origin/master master
So it isn't so much a syntactic sugar which reference the current branch: this is more default parameters of git commands.
For git pull
for instance:
Default values for
<repository>
and<branch>
are read from the "remote
" and "merge
" configuration for the current branch as set bygit-branch --track
.
Upvotes: 1