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
  • 11,022
  • 8
  • 52
  • 58
Joy
  • 4,197
  • 14
  • 61
  • 131

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,027
  • 1
  • 10
  • 23
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
  • 1,067
  • 1
  • 7
  • 18