git: branches disappearing after reset
Here’s what I did:
I merged the
kernel_common/android-3.0 into my main local branch.
Then I wanted to reset to Linux 3.0.13, so I looked into the history and found this
Problem is, the Android commits appear as untracked changes when resetting (aka. I loose all the commits).
See the image above, when I reset to a yellow commit I “loose” the blue ones, and vice-versa.
2 Solutions collect form web for “git: branches disappearing after reset”
That is perfectly correct that way.
The yellow commits do not contain the blue one and vice versa.
A reset just makes you branch pointing to the new commit, i.e. it will contain only the code at that point in time and does not know anything about a later merge.
If you want to have a new state combining a blue state with a yellow one, just merge those commits:
git checkout -b mybranch $blue_SHA1 git merge $yellow_SHA1
I finally got it: did a
git reset to the Android commit then merged the Linux commit.