There are many questions throughout SO about using VSCode as git's default editor.
The answer to all of them is to set
git config --global core.editor "code --wait"
(or "code -w"
)
However, this isn't behaving properly for me. I don't know if it's related, but I'm doing this via Remote SSH. And indeed, setting "code --wait"
and then trying an interactive rebase gives me:
$ git rebase -i --root
hint: Waiting for your editor to close the file...
So the --wait
flag is clearly doing what it's meant to do. Likewise, a new tab is opened titled "git-rebase-todo"! However, the tab is empty except for an error: "The editor could not be opened because the file was not found."
If I try to open the file in a second tab, it also shows the same error. If I close the file, the rebase proceeds normally (as if I'd accepted the default "pick-all" setting).
I've also seen some references to using "code -n --wait"
, and this does actually work!... sort of. It gets the job done, but since -n
creates a new window, this actually generates a new SSH connection for each step (if I mark 10 commits as "edit", then it will open each commit in a new window, each of which takes a few seconds to complete the SSH connection).
Is there a way for this to "just work"? A setting that works across a "Remote SSH" connection that simply opens a new tab with the git-rebase-todo file that I can modify as needed and then all changes happen on the one window I'm using?
For the record, using nano
or some other terminal-based editor works as intended: I make the changes there, and then the entire rebase happens one commit at a time on the currently open window/connection. I just want this same behavior without having to use a terminal-based editor.
Also, other operations (i.e. writing commit messages) work as expected with VSCode. The issue seems to only be when rebasing.