Reputation: 5095
I have a simple GIT environment setup for my development. One is the master that is cloned off the remote master and another is a branch (exists on remote as well). I typically work on the branch and then when I want to push my changes, I do the usual Git command sequence like:
When I do 'git push', I get a message stating :
d96001d..d1cf61c branch_release -> branch_release
[rejected] master -> master (non-fast-forward)
error: failed to push some refs to '____________'
hint: Updates were rejected because a pushed branch tip is behind its remote
hint: counterpart. If you did not intend to push that branch, you may want to
hint: specify branches to push or set the 'push.default' configuration variable
hint: to 'simple', 'current' or 'upstream' to push only the current branch.
To resolve this, i switch branches like this
git checkout master.
This brings in a horde of files into my Master that prelude with the prefix 'M' meaning they were modified. Then I do
git checkout branch_release
and it seems to bring in the same set of files into my master as well, which I am thinking should not happen since I did a GIT pull on this branch before.
My question is, is this by design that I also need to update the master before I do a push on one of it's branches? If not, how have I set this incorrectly and what should I do to ensure that i only need to update the GIT Branch.
Upvotes: 0
Views: 60
Reputation: 11002
If you want to resolve the non-fast-forword error you have to pull before you push. The error says that the remote master has commits that your master doesnt have.
If you just do a push, without specifiying the branch, it pushes all branches. You can either specify a default push branch[2] or specify it by command[1].
[1] specify it by push command parameter
So you probably want to do a (push with speficied branch)
git push origin branch_release
[2] define default push branch
I think this might be helpful:
According to this site you can specify a default push branch like this:
git config --global push.default current
[edit]
As torek pointed out simple will be the new git default value by git version 2.0. So updating will (in the future) solve this problem/question .
git config --global push.default simple
You can read more about this here:
Upvotes: 2