Skip to main content

Prevent editor invocation on `git pull` or `git merge`

While doing git pull or git merge, if it's a mechanical merge (i.e. not a fast-forward merge), git invokes the configured editor with an auto-generated merge commit message to give more flexibility to explain the merge. But the invocation of an interactive editor breaks the CI/CD workflow, hence we need something that can automatically save the merge commit with the auto-generated message without invoking the editor (given that's fine with your use case).

git provides an environment variable to make this easier -- GIT_MERGE_AUTOEDIT. We can run git pull (or git merge) with the value of this environment variable set to no i.e.:

GIT_MERGE_AUTOEDIT=no git pull

As git pull is basically a combination of git fetch and git merge, this environment variable works the same way in both git pull and git merge.

Comments

Comments powered by Disqus