How to create an upstream branch automatically?
git config --global push.autoSetupRemote true
To create an upstream branch for your local branches automatically when you push use git config --global push.autoSetupRemote true
. The next time you push a newly created branch, an upstream branch will be created for you.
The --global
flag will enable automatic upstream branches for all your git repositories.
git checkout -b test
Switched to a new branch 'test'
git push
fatal: The current branch test has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin test
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
git config --global push.autoSetupRemote true
git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 10 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 320 bytes | 320.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0), pack-reused 0
remote:
remote: Create a pull request for 'test' on GitHub by visiting:
remote: https://github.com/ptrlaszlo/playground-remote/pull/new/test
remote:
To github.com:ptrlaszlo/playground-remote.git
* [new branch] test -> test
branch 'test' set up to track 'origin/test'.
See git config to learn more about it.