Search code examples
gitgit-branchgit-rebase

Error in pushing branch after git rebase


I am new to Git. I have cut my branch from master as follows:

git co master
git fetch
git pull origin master
git co -b my_branch

Now I have been working on my that branch for past one week. Now it is ready to be deployed. So I did

git rebase master

But after rebasing while I am trying to push my branch, it keeps giving error saying I have to pull first. I finally pushed my branch as follows:

git push -f origin my_branch

I alone working on this branch. So every code on this branch has been pushed by me only. Then how it's giving such error, I don't understand. Please help.


Solution

  • Using git-rebase imply rewriting commits. Since commits have changed, git push can't do a fast-forward anymore, so you have to force it.

    You can take a look at that possible duplicate for further explanation: Git push rejected after feature branch rebase