I read a lot of articles about force push after a rebase but I still don't understand everything, I though.
What it's not clear to me is in which way a rebase is rewriting git history.
Suppose to be in this situation:
So there si a main
branch, at certain time I create a new branch (feat1)
from commit d
(on main
branch).
Then I 4 commits (e
to h)
.
In the same time some one else continues working on main
and pushes commit i
and l
.
Now I'm ready to rebase feat1
branch on main
so before doing it I pull main
:
git checkout main
git pull --rebase
git checkout feat1
git rebase main
Now the situation is this:
I solve (if the are) the conflicts, and test that everything works as I expected. Cool, it's perfect.
Now I want to push my branch but I can't. Since I did a rebase, I need to do force push. Why?
Why did I rewritten the git history?