How do I fix these false git commits?

I made a mistake while I was working and ended up with a commit tree which I didn't want. Now everything looks like this:

[master]
        A -- B -- C -- D
              \
               \
                C' -- D'
                      [HEAD]

      

I want to end up like this:

                        [master, HEAD]
        A -- B -- C -- D

      

How do I get there?

+2


source to share


1 answer


OK, you are on a separate head and you want to be on master (currently on A), but with a master in D, which is a direct descendant.

git checkout master

# This will fast-forward master to D
git merge D

      



D 'and C' will no longer be on any branch, so they will not be visible and will eventually be garbage collected.

+4


source







All Articles