How can I set up an editor to work with Git on Windows?

后端 未结 30 961
悲哀的现实
悲哀的现实 2020-11-22 13:57

I\'m trying out Git on Windows. I got to the point of trying \"git commit\" and I got this error:

Terminal is dumb but no VISUAL nor

相关标签:
30条回答
  • This worked for me:

    1. Add the directory which contains the editor's executable to your PATH variable. (E.g. "C:\Program Files\Sublime Text 3\")
    2. Reboot your computer.
    3. Change the core.editor global Git variable to the name of the editor executable without the extension '.exe' (e.g. git config --global core.editor sublime_text)

    That's it!

    NOTE: Sublime Text 3 is the editor I used for this example.

    0 讨论(0)
  • 2020-11-22 14:09

    I've just had the same problem and found a different solution. I was getting

    error: There was a problem with the editor 'ec'
    

    I've got VISUAL=ec, and a batch file called ec.bat on my path that contains one line:

    c:\emacs\emacs-23.1\bin\emacsclient.exe %*
    

    This lets me edit files from the command line with ec <filename>, and having VISUAL set means most unixy programs pick it up too. Git seems to search the path differently to my other commands though - when I looked at a git commit in Process Monitor I saw it look in every folder on the path for ec and for ec.exe, but not for ec.bat. I added another environment variable (GIT_EDITOR=ec.bat) and all was fine.

    0 讨论(0)
  • 2020-11-22 14:10

    For Atom you can do

    git config --global core.editor "atom --wait"
    

    and similar for Visual Studio Code

    git config --global core.editor "code --wait"
    

    which will open up an Atom or Visual Studio Code window for you to commit through,

    or for Sublime Text:

    git config --global core.editor "subl -n -w"
    
    0 讨论(0)
  • 2020-11-22 14:12

    I needed to do both of the following to get Git to launch Notepad++ in Windows:

    • Add the following to .gitconfig:

      editor = 'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin
      
    • Modify the shortcut to launch the Git Bash shell to run as administrator, and then use that to launch the Git Bash shell. I was guessing that the context menu entry "Git Bash here" was not launching Notepad++ with the required permissions.

    After doing both of the above, it worked.

    0 讨论(0)
  • 2020-11-22 14:13

    Thanks to the Stack Overflow community ... and a little research I was able to get my favorite editor, EditPad Pro, to work as the core editor with msysgit 1.7.5.GIT and TortoiseGit v1.7.3.0 over Windows XP SP3...

    Following the advice above, I added the path to a Bash script for the code editor...

    git config --global core.editor c:/msysgit/cmd/epp.sh
    

    However, after several failed attempts at the above mentioned solutions ... I was finally able to get this working. Per EditPad Pro's documentation, adding the '/newinstance' flag would allow the shell to wait for the editor input...

    The '/newinstance' flag was the key in my case...

    #!/bin/sh
    "C:/Program Files/JGsoft/EditPadPro6/EditPadPro.exe" //newinstance "$*"
    
    0 讨论(0)
  • 2020-11-22 14:14

    Based on VonC's suggestion, this worked for me (was driving me crazy):

    git config --global core.editor "'C:/Program Files (x86)/Sublime Text 3/subl.exe' -wait"
    

    Omitting -wait can cause problems, especially if you are working with Gerrit and change ids that have to be manually copied to the bottom of your commit message.

    0 讨论(0)
提交回复
热议问题