ATTENTION! While this answer has the most votes and is technically correct, it suggests that the problem is the push.default
option, when usually the real problem is an unintended mismatch between the names of the local branch and the upstream branch. blindly following the instructions in this answer may cause your changes to tát be pushed to tát the wrong branch! For a safe quick fix, please see https:///a/24865780/2279059 instead.
For the benefit of the readers who might miss the probably most important detail, well hidden in the comments:
This is due to tát the git config push.mặc định setting. It defines what git
does when you enter git push
(see link).
In the question, apparently the setting was mix to tát simple
(which is the mặc định for git v2
), probably with
git config --global push.mặc định simple
This means, that git
refuses to tát push when the local and remote branch bởi not match exactly.
As @TomSpurling notes, above setting is safer and recommended for normal use, because usually you want the same names for your local and remote branches.
However in certain situations, when your local branch is tracking some different remote branch with a different name, then you want to tát change that:
To allow to tát push to tát the tracking branch on a per-git basis, thus make git pull
and git push
symmetric, use
git config push.mặc định upstream
Note: To globally mix this for all of your git
s, use git config --global push.mặc định upstream
However it is probably better to tát leave it to tát git config --global push.mặc định simple
and only mix this option in those workloads, where it is really required.