Reputation: 1222
I have a git repo with a master that is set up in upstream, and a dev branch which is getting every stream from this master.
I have some commited changes on my dev branch that are useful only for this specific branch and not for the master, and I
my current branch is :
git status
On branch dev
Your branch is ahead of 'master' by 2 commits.
my commits are visible when I do
git diff origin/master..HEAD
my branch is up to date ( and goes through master as it was doing before) :
git pull
From .
* branch master -> FETCH_HEAD
Already up-to-date.
But when I push, I got bashed :
git push origin
To https://my_git.git
! [rejected] dev -> dev (non-fast-forward)
error: failed to push some refs to 'https://my_git.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
Any tips would be appreciated, I had a look on several posts like this : git push rejected non-fast-forward or this Git non-fast-forward rejected , but none of them seems to work in my case.
Thanks
Upvotes: 2
Views: 2277
Reputation: 142114
Your problem is here:
git push origin
You did not specify any branch to push.
Assuming you are using git <2.0 you must set the branches that you wish to pull/push
. In your case its trying to push ALL your branches and one of them generate the error.
This will for it for you
# get all latest changes from the remote
git fetch --all
# merge the changes to the local repository
git pull origin dev
# push the changes to the remote
git push origin dev
Git v2.0 Release Notes
Backward compatibility notes
When "git push [$there]" does not say what to push, we have used the traditional "matching" semantics so far (all your branches were sent to the remote as long as there already are branches of the same name over there).
In Git 2.0, the default is now the "simple" semantics, which pushes:
only the current branch to the branch with the same name, and only when the current branch is set to integrate with that remote branch, if you are pushing to the same remote as you fetch from; or
only the current branch to the branch with the same name, if you are pushing to a remote that is not where you usually fetch from.
You can use the configuration variable "push.default" to change this. If you are an old-timer who wants to keep using the "matching" semantics, you can set the variable to "matching", for example. Read the documentation for other possibilities.
Upvotes: 1