OK, I thought this was a simple git scenario, what am I missing?
I have a master
branch and a feature
branch. I do some work on master
, some on feature
, and then some more on master
. I end up with something like this (lexicographic order implies the order of commits):
A--B--C------F--G (master)
\
D--E (feature)
I have no problem to git push origin master
to keep the remote master
updated, nor with git push origin feature
(when on feature
) to maintain a remote backup for my feature
work. Up until now, we're good.
But now I want to rebase feature
on top of the F--G
commits on master, so I git checkout feature
and git rebase master
. Still good. Now we have:
A--B--C------F--G (master)
\
D'--E' (feature)
Problem: the moment I want to backup the new rebased feature
branched with git push origin feature
, the push is rejected since the tree has changed due to the rebasing. This can only be solved with git push --force origin feature
.
I hate using --force
without being sure I need it. So, do I need it? Does the rebasing necessarily imply that the next push
should be --force
ful?
This feature branch is not shared with any other devs, so I have no problem de facto with the force push, I'm not going to lose any data, the question is more conceptual.
--force
is not a monster it's a feature. You can use it when is required. – Alcinia