Set the default push branch name in Git

Manually specifying the remote branch name when pushing can be a hassle. Git provides a way to automate this process by setting the default push branch name to the current branch name.

Using git config push.default current will configure Git to use the name of the current branch as the default remote branch name. This setting is particularly useful when local branches are expected to have the same name as their remote counterparts.

Using the --global flag will set this configuration globally on your machine.

# Syntax: git config [--global] push.default current

git config --global push.default current

git checkout -b my-branch
git push -u
# Pushes to origin/my-branch

More like this

  • Collection · 33 articles

    Git Branches

    Master git branch commands with this article collection of simplified git documentation and tips.

  • Git ·

    List all Git aliases

    Did you set up a lot of Git aliases and forgot what they are? List them all with this command.