What's the behavior of git push --force
when no upstream branch exists?
Will I get something like fatal: The current branch branch_name has no upstream branch
, as would happen with a normal push, or would the upstream branch be "forcefully" created?
--force
does not change the behaviour of git push
without an upstream set (when no push.default
and push.autoSetupRemote
config is set) empirically with git 2.40.0.
$ git checkout -b dev/test
Switched to a new branch 'dev/test'
$ git push
fatal: The current branch dev/test has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev/test
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
$ git push --force
fatal: The current branch dev/test has no upstream branch.
To push the current branch and set the remote as upstream, use
git push --set-upstream origin dev/test
To have this happen automatically for branches without a tracking
upstream, see 'push.autoSetupRemote' in 'git help config'.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.