Back
I am fairly new to git yet currently using it to manage our code in a team environment. I had some rebasing issues and I fixed them using
git checkout --ours filename.txtgit add filename.txtgit rebase --continue
git checkout --ours filename.txt
git add filename.txt
git rebase --continue
Now I wish to push my changes, and so running the following command
$ git push origin feature/my_feature_branch
gives me the following error:
To ssh://[email protected]:7999/repo/myproject.git ! [rejected] feature/my_feature_branch -> feature/my_feature_branch (non-fast-forward)error: failed to push some refs to 'ssh://[email protected]:7999/repo/myproject.git'hint: Updates were rejected because the tip of your current branch is behindhint: its remote counterpart. Merge the remote changes (e.g. 'git pull')hint: before pushing again.hint: See the 'Note about fast-forwards' in 'git push --help' for details.
To ssh://[email protected]:7999/repo/myproject.git
! [rejected] feature/my_feature_branch -> feature/my_feature_branch (non-fast-forward)
error: failed to push some refs to 'ssh://[email protected]:7999/repo/myproject.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Merge the remote changes (e.g. 'git pull')
hint: before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
What can I do to get rid of the error?
P.S.: I am avoiding to use the --force option as much as possible.
It seems like, there were new commits being pushed between your last git fetch and git push. In this case, you are required to repeat your steps and rebase my_feature_branch one more time.
git fetchgit rebase feature/my_feature_branchgit push origin feature/my_feature_branch
git fetch
git rebase feature/my_feature_branch
git push origin feature/my_feature_branch
After the git fetch I recommend examining the situation with gitk --all.
31k questions
32.8k answers
501 comments
693 users