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

后端 未结 30 1002
悲哀的现实
悲哀的现实 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:15

    I had PortableGit 1.6 working fine, but after upgrading to the PortableGit 1.7 Windows release, I had problems. Some of the Git commands opens up the Notepad++.exe fine, but some don't, especially Git rebase behaves differently.

    The problem is some commands run the Windows cmd process and some use the Unix cmd process. I want to give startup attributes to Notepad++ editor, so I need to have a customized script. My solution is this.

    1. Create a script to run an appropriate text editor. The script looks weird, but it handles both the Windows and Unix variation.

      c:/PortableGit/cmd/git-editor.bat

      #!/bin/sh
      # Open a new instance
      
      function doUnix() {
        "c:\program files\notepad++\notepad++.exe" -multiInst -nosession -notabbar $*
        exit
      }
      
      doUnix $*
      
      :WINCALL
      "c:\program files\notepad++\notepad++.exe" -multiInst -nosession -notabbar %*
      
    2. Set the global core.editor variable

      The script was saved to git/cmd folder, so it's already in a gitconsole path. This is mandatory as a full path may not work properly.

      git config --global core.editor "git-editor.bat"
      

    Now I can run the git commit -a and git rebase -i master commands. Give it a try if you have problems in the Git Windows tool.

提交回复
热议问题