Is there git shorthand to reference the current branch I'm on?

I really love the ability to use - as shorthand to refer to the last branch I was on.

I was wondering if there is shorthand to refer to the current branch I am on? For example,

Before

$(dev/my_branch)    git push -f origin dev/my_branch
$(dev/my_branch)    git branch --set-upstream-to=origin/dev/my_branch

After

$(dev/my_branch)    git push -f origin .
$(dev/my_branch)    git branch --set-upstream-to=origin/.

Upvotes: 3

Views: 1259

Answers (3)

Maksym Dudyk
Maksym Dudyk

Reputation: 1164

The shorthand to refer to the current branch is --:

Suppose, you are on a branch called 'feature/old-branch-name`, wishing to rename it.

git branch -m -- feature/new-branch-name

The current branch was renamed!

Upvotes: 5

Rakmo
Rakmo

Reputation: 1982

git push origin HEAD

HEAD will always refer to the latest Commit of your current branch.

Alternative:

You can configure git to push to the current branch using the following command

git config --global push.default current

then just do

git push 

this will push the code to your current branch.

Upvotes: 3

user2199860
user2199860

Reputation: 818

HEAD will refer to the current branch

Upvotes: -1

Related Questions