Skip to content

Instantly share code, notes, and snippets.

@pozdneev
Last active March 5, 2023 16:21
Show Gist options
  • Save pozdneev/be069f887344fe56eca26e93c09d574f to your computer and use it in GitHub Desktop.
Save pozdneev/be069f887344fe56eca26e93c09d574f to your computer and use it in GitHub Desktop.
Avoiding conflicts in git when merging a squashed commit from main into feature branch

These are the Mermaid versions of the diagrams I created for my https://stackoverflow.com/q/68229841/1800052 question.

gitGraph
    commit
    commit id: "A"

    branch feature1
    commit id: "B"
    commit id: "C"

    checkout main
    commit id: "D"

    checkout feature1
    branch feature2
    commit id: "E"
    commit id: "F"

    checkout main
    merge feature1 id: "G" tag: "merge --squash"

    checkout feature2
    merge main id: "H" tag: "merge"
Loading
gitGraph
    commit
    commit id: "A"

    branch feature1
    commit id: "B"
    commit id: "C"

    checkout main
    commit id: "D"

    checkout feature1
    branch feature2
    commit id: "E"
    commit id: "F"

    checkout main
    merge feature1 id: "G" tag: "merge --squash"

    checkout feature1
    merge main id: "G'" tag: "merge"

    checkout feature2
    merge feature1 id: "H'" tag: "merge"
Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment