git: branches disappearing after reset

Here’s what I did:

I merged the kernel_common/android-3.0 into my main local branch.

  • Git Mess! Commits in the wrong branch
  • How can I add a new file to my Git repository?
  • Line endings messed up in Git - how to track changes from another branch after a huge line ending fix?
  • Mercurial: How to deal with one branch that has two heads
  • What is trunk, branch and tag in Subversion?
  • Default behavior of “git push” without a branch specified
  • 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.

  • Swap “Latest release” on github
  • Is there a faster way to integrate a feature branch?
  • how to get trunk code from repository? (redmine,svn)
  • merging some differences but not all
  • Git merge conflict with 500 files added on local and origin
  • How to use my Github-Account on my PC instead of some other account?
  • 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.

    Thanks!

    Git Baby is a git and github fan, let's start git clone.