0

I have a Github repository which originally had two branches master and dev.
I merged the dev branch, deleted it and now I only have one master branch.
The git log --oneline --all --graph output looks like this:

git log

I was expecting to have only one "line" of commits, how can I fix it?

Chris
  • 935
  • 3
  • 10
  • 21
  • 1
    "I was expecting to have only one "line" of commits" Can you elaborate on this? What problem is to be solved here? (No merge will produce the result you expected. `git merge` is creating a new commit, no past commit will be changed in any way by a merge.) – Romain Valeri Feb 03 '20 at 20:09
  • 1
    You didn't delete the branch; you delete the branch *head*, which was just a pointer to a particular commit, in this case a merge commit with 2 parents. – chepner Feb 03 '20 at 20:16
  • @Romain: I just want to have only one clean branch. e.g. commit `c3cee86` would be at the same level than its parent. – Chris Feb 03 '20 at 20:31

1 Answers1

2

Do you just need to undo that last merge commit? The easiest option is probably using the squash option for merging:

See git-merge docs:

--squash

Produce the working tree and index state as if a real merge happened, but do not actually make a commit or move the HEAD, nor record $GIT_DIR/MERGE_HEAD to cause the next git commit command to create a merge commit. This allows you to create a single commit on top of the current branch whose effect is the same as merging another branch (or more in case of an octopus).

Just undo the merge commit and then remerge with the --squash option enabled.

doggie_breath
  • 782
  • 1
  • 6
  • 21