0

I have 7 commits in my git and i checkout the 5th commit and then I created a branch from it. after that the 6th commit and the 7th commit disappeared? I checked both branches the master and the new one by using gui git apps and by git log and I find nothing about me 6th and 7th commits.

Ali Husham
  • 816
  • 10
  • 31
  • 2
    Hi, please [edit] your question to include more details. What commands did you run? What did your commit tree look like before and after? Where did you expect these commits to show up? – IMSoP Aug 06 '20 at 17:06
  • sounds ike you must have been committing not to `master` but to a `detached HEAD`. you can just run `git reflog` to find the missing commits, then `checkout` a live branch and `cherry-pick` said commits onto it. or you can search and probably there are plenty of scenarios similar to whatever yours is, although it's rather vague right now. – underscore_d Aug 06 '20 at 17:06
  • can you share the output of `git log --oneline --graph --all` this can me understand the structure of yours commits. – surajs1n Aug 06 '20 at 17:22

1 Answers1

0

Well if you have 7 commits, and you are branching out at 5th, so your branch won't have further commits. Take a look at commits history (suppose branch is named new_branch and you branched out from master):

    new_branch
      ↓
C4 <- C5 <- C6 <- C7
                  ↑
                master

new_branch points to fifth commit and cannot see it's descendant. Try using git log master, it will show history of master branch.

See this SO post for reference.

Michał Turczyn
  • 32,028
  • 14
  • 47
  • 69