less than 1 minute read

Due to the complicated naming covention, sometimes it is not easy to remember and type in your current working branch name. The following command lets you get the branch name

git branch | sed -n -e "s/^\* \(.*\)/\1/p"

and you should be able to set the output to the variable

CURRENT_BRANCH=`git branch | sed -n -e "s/^\* \(.*\)/\1/p"`; git push origin $CURRENT_BRANCH

when you push your local branch to the remote.