Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

stop git merge from opening text editor

Tags:

git

merge

Every time I run a git merge command it opens the text editor asking me to add an extra message.

How can I stop git from opening the editor & simply merging my branches? Because when it opens the editor it doesn't complete the merge, even if I add an extra message & save the file, the terminal just hangs on my git merge command.

Merge branch 'my-feature-branch' into main-development  # Please enter a commit message to explain why this merge is necessary, # especially if it merges an updated upstream into a topic branch. #  # Lines starting with '#' will be ignored, and an empty message aborts # the commit. 
like image 237
Holly Avatar asked Jul 07 '14 11:07

Holly


1 Answers

Use the --no-edit option, you can read about it in the documentation.

Note that using the default message is discuraged, since it provides no meaningful information about the changes introduced with this merge.


On a sidenote: To continue merging you probably have to close the editor.


If you have a git version prior to 1.7.8 there is still a way to achieve what you want by using the env command.

env GIT_EDITOR=: git merge <ref-you-want-to-merge> 

For easier usage you could create an alias.

git config --global alias.merge-no-edit '!env GIT_EDITOR=: git merge' 

Which then can be used using git merge-no-edit <ref-you-want-to-merge>.

like image 146
Sascha Wolf Avatar answered Sep 19 '22 18:09

Sascha Wolf