0

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.

2540625
  • 10,156
  • 8
  • 46
  • 53
Joy
  • 3,641
  • 11
  • 49
  • 92

2 Answers2

2

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

Community
  • 1
  • 1
fpietka
  • 1,007
  • 1
  • 10
  • 22
0

You can also

git push origin +my_branch

This will make sure all the commits done by you in my_branch are at the top than the commits from rebasing.

dgupta3091
  • 957
  • 1
  • 6
  • 17