Automatically push current branch and set the remote as upstream.
This does not work for currently packaged git version.
$ git --version
git version 2.34.1
Create new branch.
$ git checkout -b test-push
Switched to a new branch 'test-push'
Try to push changes.
$ git push
fatal: The current branch test-push has no upstream branch. To push the current branch and set the remote as upstream, use git push --set-upstream origin test-push
Use more recent git version.
$ git --version
git version 2.38.1
Set upstream on default push when no upstream tracking exists for the current branch.
$ git config --global --add --bool push.autoSetupRemote true
Push changes.
$ git push
Warning: Permanently added '[bitbucket.example.org]:1234' (RSA) to the list of known hosts. Total 0 (delta 0), reused 0 (delta 0) remote: remote: Create pull request for test-push: remote: http://bitbucket.example.org/projects/test_push/compare/commits?sourceBranch=refs/heads/test-push remote:To ssh://bitbucket.example.org/projects/test_push.git * [new branch] test-push -> test-push * branch 'test-push' set up to track 'origin/test-push'.
Cool.