From e76b43d8ff5382b65e0c623f604a7a22ae5a1bff Mon Sep 17 00:00:00 2001 From: Chalarangelo Date: Tue, 22 Jun 2021 20:37:18 +0300 Subject: [PATCH] Add set default push branch --- snippets/set-default-push-branch.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 snippets/set-default-push-branch.md diff --git a/snippets/set-default-push-branch.md b/snippets/set-default-push-branch.md new file mode 100644 index 000000000..e4fe3fb06 --- /dev/null +++ b/snippets/set-default-push-branch.md @@ -0,0 +1,20 @@ +--- +title: Set default push branch name +tags: configuration,branch,intermediate +firstSeen: 2021-06-30T05:00:00-04:00 +--- + +Use the name of the current branch when pushing by default as the name of the remote branch. + +- Use `git config push.default current` to set the name of the remote branch to the one of the current local branch as the default. +- You can use the `--global` flag to configure this option globally. + +```shell +git config [--global] push.default current +``` + +```shell +git checkout -b my-branch +git push -u +# Pushes to origin/my-branch +```