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

后端 未结 30 963
悲哀的现实
悲哀的现实 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条回答
  • 2020-11-22 14:20

    This works for PowerShell and cmder 1.2 (when used with PowerShell). In file ~/.gitconfig:

    [core]
        editor = 'c:/program files/sublime text 3/subl.exe' -w
    

    How can I make Sublime Text the default editor for Git?

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

    I also use Cygwin on Windows, but with gVim (as opposed to the terminal-based Vim).

    To make this work, I have done the following:

    1. Created a one-line batch file (named git_editor.bat) which contains the following: "C:/Program Files/Vim/vim72/gvim.exe" --nofork "%*"
    2. Placed git_editor.bat on in my PATH.
    3. Set GIT_EDITOR=git_editor.bat

    With this done, git commit, etc. will correctly invoke the gVim executable.

    NOTE 1: The --nofork option to gVim ensures that it blocks until the commit message has been written.

    NOTE 2: The quotes around the path to gVim is required if you have spaces in the path.

    NOTE 3: The quotes around "%*" are needed just in case Git passes a file path with spaces.

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

    This is my setup to use Geany as an editor for Git:

    git config --global core.editor C:/path/to/geany.bat
    

    with the following content in geany.bat:

    #!/bin/sh
    "C:\Program Files\Geany\bin\Geany.exe" --new-instance "$*"
    

    It works in both a DOS console and msysgit.

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

    I've had difficulty getting Git to cooperate with WordPad, Komodo Edit and pretty much every other editor I give it. Most open for editing, but Git clearly doesn't wait for the save/close to happen.

    As a crutch, I've just been doing i.e.

    git commit -m "Fixed the LoadAll method"
    

    to keep things moving. It tends to keep my commit messages a little shorter than they probably should be, but clearly there's some work to be done on the Windows version of Git.

    The GitGUI also isn't that bad. It takes a little bit of orientation, but after that, it works fairly well.

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

    I prefer to use Emacs. Getting it set up can be a little tricky.

    1. Download Emacs and unpack it somewhere like c:\emacs.
    2. Run c:\emacs\bin\addpm.exe. You need to right-click and "Run as Administrator" if you are using Windows Vista or above. This will put the executables in your path.
    3. Add (server-start) somewhere in your .emacs file. See the Emacs Windows FAQ for advice on where to put your .emacs file.
    4. git config --global core.editor emacsclientw

    Git will now open files within an existing Emacs process. You will have to run that existing process manually from c:\emacs\bin\runemacs.exe.

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

    Edit .gitconfig file in c:\Users\YourUser folder and add:

    [core]
    editor = 'C:\\Program files\\path\\to\\editor.exe'
    
    0 讨论(0)
提交回复
热议问题