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

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

    This is the one symptom of greater issues. Notably that you have something setting TERM=dumb. Other things that don't work properly are the less command which says you don't have a fully functional terminal.

    It seems like this is most commonly caused by having TERM set to something in your global Windows environment variables. For me, the issue came up when I installed Strawberry Perl some information about this is on the msysgit bug for this problem as well as several solutions.

    The first solution is to fix it in your ~/.bashrc by adding:

    export TERM=msys
    

    You can do this from the Git Bash prompt like so:

    echo "export TERM=msys" >> ~/.bashrc
    

    The other solution, which ultimately is what I did because I don't care about Strawberry Perl's reasons for adding TERM=dumb to my environment settings, is to go and remove the TERM=dumb as directed in this comment on the msysgit bug report.

    Control Panel/System/Advanced/Environment Variables... (or similar, depending on your version of Windows) is where sticky environment variables are set on Windows. By default, TERM is not set. If TERM is set in there, then you (or one of the programs you have installed - e.g. Strawberry Perl) has set it. Delete that setting, and you should be fine.

    Similarly if you use Strawberry Perl and care about the CPAN client or something like that, you can leave the TERM=dumb alone and use unset TERM in your ~/.bashrc file which will have a similar effect to setting an explicit term as above.

    Of course, all the other solutions are correct in that you can use git config --global core.editor $MYFAVORITEEDITOR to make sure that Git uses your favorite editor when it needs to launch one for you.

提交回复
热议问题