Skip to content

Instantly share code, notes, and snippets.

@juev
Created March 20, 2025 09:29
Show Gist options
  • Save juev/4d2b0fa24d465eef606912e456eb85c9 to your computer and use it in GitHub Desktop.
Save juev/4d2b0fa24d465eef606912e456eb85c9 to your computer and use it in GitHub Desktop.

Merge conflicts in go.sum

Источник

When rebasing a branch in a Go project, you may encounter git conflicts on your dependencies. While the go.mod file should still be handled manually, it seems safe to automatically merge the go.sum file by keeping both versions, and running a go mod tidy afterwards.

Git can handle the first part by itself:

    # if you don't already have a global attributes file:
    git config --global core.attributesfile $HOME/.gitattributes
     
    # then tell git to keep both versions when merging go.sum
    echo "go.sum merge=union" >> $(git config --global core.attributesfile)

As always when dealing with dependencies and go.mod, remember to cleanup with go mod tidy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment