We have a policy to not bloat commit history, as it is a big project. So what I usually do, is on my feature branch, I push -f origin featbranch
daily, and when finished, I issue a PR.
This approach left me damaged today.
I finished my work on my featbranch
. After running all tests etc. successfully, I did a first push -f origin featbranch
. origin
is my own clone of the repo we work, upstream
being the one the PR is issued to.
Then I recalled that upstream/master
may have changed already, so in order to keep my featbranch
up-to-date, I wanted to rebase:
git fetch upstream master
git rebase upstream/master
git push -f origin featbranch
No errors. I assumed all was ok (I had just double-checked all tests etc....), but to may horrific dismay, I now realize that all my latest changes are lost.
I am left with a strange situation now, and I don't know what happened. In fact it looks like I am left with the very first commit on featbranch
: there is a file in featbranch
which is definitely not in upstream/master
. So I am baffled and don't know what happened here, github says the commit in that branch is from 13 days ago when I actually pushed yesterday.
I guess, due to the -f origin featbranch
, that my latest commit can't be recovered - not locally, not on github. I will ignore the policy above from now on and always do daily pushes but without forcing. Nevertheless I would like to understand what happened here.