You can set the GIT_MERGE_AUTOEDIT environment variable in Git to control whether Git opens the default editor during a merge commit. Here's how you can do it:
Run this command in your terminal:
export GIT_MERGE_AUTOEDIT=no # Prevents Git from opening the editoror
export GIT_MERGE_AUTOEDIT=yes # Allows Git to open the editorThis setting will only last until you close the terminal session.
To make this setting permanent, add the export command to your shell configuration file:
- For Bash (
~/.bashrcor~/.bash_profile):echo 'export GIT_MERGE_AUTOEDIT=no' >> ~/.bashrc source ~/.bashrc
- For Zsh (
~/.zshrc):echo 'export GIT_MERGE_AUTOEDIT=no' >> ~/.zshrc source ~/.zshrc
- Command Prompt (cmd):
set GIT_MERGE_AUTOEDIT=no
- PowerShell (temporary):
$env:GIT_MERGE_AUTOEDIT = "no"
- PowerShell (permanent in profile script):
[System.Environment]::SetEnvironmentVariable("GIT_MERGE_AUTOEDIT", "no", "User")
Now, Git will automatically skip opening the editor during merge commits if set to no.