'Shortcut for pushing local branch to a new remote branch with the same name

My workflow with new branches is:

git checkout -b <new branch name>
// making changes, commit the changes
git push -u origin <new branch name>

Is there any way to push the local branch to a new remote branch without writing the name of the branch again (local and remote branch will have the same name)? Everyday I make at least 1 feature branch with really long name and at the end of the day I have to go back to JIRA board to get project IDs and other things required for the convention. I'm just curious if there is some hack to get the local branch name and pass it directly to git push -u origin <local branch name>

git


Solution 1:[1]

I do this, HEAD automatically refers to your current branch (technically current commit, but don't worry about that)

git push -u origin HEAD

Solution 2:[2]

Try git config --global push.default current and then just git push -u origin

Solution 3:[3]

To push the current branch and set the remote as upstream, use below command:

git push --set-upstream origin yourBranchName

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 QurakNerd
Solution 2 jjuraszek
Solution 3 Bayram Binbir