I don't often have to modify multiple commit messages, but it has happened once or twice and I don't ever remember seeing this. I hope someone else has. When I git rebase -i HEAD~7
, the expected list opens in vi exactly as expected. I change the pick
values to edit
where appropriate and then :wq
.
Could not execute editor
The core.editor
setting开发者_JS百科 in my global .gitconfig
is vi
(I've also changed it to vim
in a wildly desperate move). I tried using mate
, but that didn't even open the initial list properly so I changed it back.
I'm using v1.7.3 and would welcome any suggestions.
Yesterday was just one of those days. On a lark, I decided to set the full path to vi (e.g. /usr/bin/vi
) rather than just the executable. Now everything works. I have to admit that I don't get it since vi
is perfectly executable on its own (my $EDITOR
env variable is also set to vi
), but it's working and my technical karma hasn't been so great lately so maybe I just shouldn't question the deities will...
The following command
git config --global core.editor /usr/bin/vim
fixes it.
[edit]
Now I see that someone already posted it in the comments. Hope its still helpful for some blind folks like me.
Unlike with the other answers here so far, for me using the absolute path to vi, and setting the git core.editor
config, were not sufficient to solve the problem. (Those were already in place.)
In my situation, the problem was solved by adding the -f
flag to the vi command:
git config --global core.editor '/usr/bin/vi -f'
Once this -f
option is in place, I can use git rebase -i
, and when I save-and-exit the commit list, the rebase proceeds as it should instead of giving the "could not execute editor" error.
The vim man page says with regard to option -f
,
For the GUI version, Vim will not fork and detach from the shell it was started in. ... This option should be used when Vim is executed by a program that will wait for the edit session to finish (e.g. mail).
Well I'm not using a GUI version, that I know of. I'm running git
at the bash command line in a terminal window on masOS Sierra 10.12.6. But since git rebase -i
waits for the edit session to finish, I suppose that's why the -f
option is necessary here. Maybe vim (without -f
) tries to fork/detach from the shell for some reason I haven't been able to figure out.
I had this issue, and it was caused by some part of the vcscommand plugin for vim. Starting vim with any of these commands resulted in exit code 1 ("error"):
vi
vim
But these gave me exit code 0 ("success"):
/usr/bin/vi
/usr/bin/vim
vi -u NONE
vim -u NONE
I was able to trace it back to the specific plugin by disabling ~/.vimrc
and files in ~/.vim
by renaming them and running vi -c q ; echo $?
to quickly run vim and print the exit code.
For me, it was a problem with my .vimrc. Temporarily renaming that file fixed it. Followed by debugging my .vimrc. This is very similar to ignu's experience.
If you wanted to for whatever reason use sublime you could do something like the following in your global config file:
git config --global core.editor "/Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl"
It just took me a while to track down my problem to one of my plugins.
(specifically, it was https://github.com/ervandew/supertab)
I guess that's the downside to automatically updating all my plugins.
So best advice, disable half your vimrc and plugins. If that doesn't help, the problem's with your other half.
I was trying to squash commits as shown here https://www.youtube.com/watch?v=V5KrD7CmO4o. My git editor (notepad++) opened up in the rebasing step. But, in the amend commit message step, I saw the "Could not execute editor" issue. It probably happened because the git editor settings were wrong and also because I installed notepad++ in a non-standard location on my windows system. That is, 'git config core.editor' gave me notepad++ -multilnst- nosession
.
To fix the issue, provide full path like this :
git config --global core.editor "'C:\CustomFolder\NPP\notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
Refer : https://www.youtube.com/watch?v=YLxdkcT6H4g
Are you sure that /usr/bin/vim was on 1.7.3? I had the same issue because I had the backup plugin installed which is only supported in 1.7.3 and for some reason /usr/bin/vim was all of a sudden downgraded to 1.7.2, perhaps because of a major update of XCode...
I had this problem as well when I had already had vim open for a rebase in another terminal. I had started the rebase, got interrupted, and when I came back I tried it again from scratch in the other terminal, not realizing I was in the middle of the same rebase elsewhere. Just finishing the vim rebase session in the other terminal worked fine.
Oddly enough, just trying it again worked for me.
My core.editor and $EDITOR variables are not set.
For me, using windows: close the current terminal, and open another one(win+R, type 'cmd', then 'enter'), then it suddenly works.
Another option is to use nano
editor.
$ whereis nano
$ git config --global core.editor path/to/nano
Fixes it.
VS Code solution:
git config --global core.editor "/Applications/Visual\ Studio\ Code.app/Contents/MacOS/Electron"
精彩评论