Git push rejected “non-fast-forward”

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.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://git@coderepo.com:7999/repo/myproject.git
 ! [rejected]        feature/my_feature_branch -> feature/my_feature_branch (non-fast-forward)
error: failed to push some refs to 'ssh://git@coderepo.com: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.

Answers


It looks, that someone pushed new commits between your last git fetch and git push. In this case you need to repeat your steps and rebase my_feature_branch one more time.

git fetch
git rebase feature/my_feature_branch
git push origin feature/my_feature_branch

After the git fetch I recommend to examine situation with gitk --all.


Probably you did not fetch the remote changes before the rebase or someone pushed new changes (while you were rebasing and trying to push). Try these steps:

#fetching remote 'feature/my_feature_branch' branch to the 'tmp' local branch 
git fetch origin feature/my_feature_branch:tmp

#rebasing on local 'tmp' branch
git rebase tmp

#pushing local changes to the remote
git push origin HEAD:feature/my_feature_branch

#removing temporary created 'tmp' branch
git branch -D tmp

Need Your Help

Java: Accounting for taskbars/menubars/etc when placing a window on the desktop?

java swing

When my program starts, the main window places itself where it was when it was last closed. I want to modify this behavior some so if the window is off-screen (or partially off-screen) it moves it...

Internet Explorer submit button styling

css image internet-explorer button css-selectors

I'm making a web application and I got the design for it from a sub-contracted design company. The design is pretty nice, I like it, but I've stumbled across one thing I'm not sure how to implement

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.