为什么 Windows 上的 git diff 警告“终端功能不全”?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7949956/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Why does git diff on Windows warn that the "terminal is not fully functional"?
提问by PortalHymaner
I'm using msysgit 1.7.7.1on Windows. I get an error when using git diff
. What is causing this? Is there no diff tool included in msysgit? What should I do?
我在 Windows 上使用msysgit 1.7.7.1。使用时出现错误git diff
。这是什么原因造成的?msysgit 中没有包含差异工具吗?我该怎么办?
WARNING: terminal is not fully functional
警告:终端功能不全
采纳答案by manojlds
For Git Bash, this can be fixed by adding the following line to ~/.bashrc:
对于 Git Bash,这可以通过在 ~/.bashrc 中添加以下行来解决:
export TERM=cygwin
-or-
-或者-
export TERM=msys
The first seems to be the original by git for windows, the second a popular known form to "heal" as well.
第一个似乎是 git for windows 的原始版本,第二个是流行的已知形式,也可以“治愈”。
The problem can be caused if some other program (like for example Strawberry Perl) sets the TERM
system environment variables.
如果某些其他程序(例如Strawberry Perl)设置了TERM
系统环境变量,则可能会导致该问题。
回答by teleball
If you are having issues in cmd.exe, for instance, see the warning here:
例如,如果您在 cmd.exe 中遇到问题,请参阅此处的警告:
Then simply set your environment variables and include TERM=msys. After that, each time you open a cmd.exe, your variable will be set correctly.
然后只需设置您的环境变量并包含 TERM=msys。之后,每次打开 cmd.exe 时,您的变量都会被正确设置。
NOW YOU MUST RESTART YOUR SHELL(CMD.EXE). Just run a new one. And from there, you should have no more issues. Again:
现在您必须重新启动您的外壳(CMD.EXE)。只需运行一个新的。从那里开始,您应该不会再有任何问题了。再次:
回答by Anatoly R
Above answers was not fully worked for me, so I did: Add
以上答案对我来说并不完全适用,所以我做了:添加
export TERM=msys
to "[githome]/etc/profile" at the top but it made changes only for git bash. Then I added
到顶部的“ [githome]/etc/profile”,但它仅对 git bash 进行了更改。然后我加了
@set TERM=msys
to "[githome]/cmd/git.cmd" after @setlocal (I installed only git run from command line). May be this decision not truly good but it works for me and there are not any terminal warnings. (I use git version 1.7.10.msysgit.1).
@setlocal之后到“ [githome]/cmd/git.cmd”(我只从命令行安装了 git run)。可能这个决定不是很好,但它对我有用,并且没有任何终端警告。(我使用 git 版本 1.7.10.msysgit.1)。
回答by Mr_Spock
回答by John Weldon
I work in powershell and I have the git executable directly in my path.
我在 powershell 中工作,我的路径中直接有 git 可执行文件。
None of the suggested answers worked, but I found a solution that works for me.
建议的答案均无效,但我找到了适合我的解决方案。
I added a line in my powershell profile:
我在我的 powershell 配置文件中添加了一行:
$env:TERM="msys"
Which fixed the problem for me.
这为我解决了问题。
回答by Felix
A quick & dirty solution in my case turned out to be to use the --no-pager
option.
在我的情况下,一个快速而肮脏的解决方案是使用该--no-pager
选项。
By default, some git commands (like log
) will use a pager like less
if they expect the output to be long. Pagers require things like scrolling text up and down with the arrow keys, which sometimes doesn't work if the assumptions about what kind of terminal you're on are wrong (this is what the "not fully functional" means).
默认情况下,一些 git 命令(如log
)将使用寻呼机,就像less
他们希望输出很长一样。寻呼机需要诸如使用箭头键上下滚动文本之类的操作,如果关于您使用的终端类型的假设是错误的(这就是“功能不全”的意思),这有时不起作用。
If you know ahead of time that your output will be short, or you just want it to dump output to the terminal and leave the scrolling up to your terminal program, you can override this and not use a pager at all, e.g.:
如果你提前知道你的输出会很短,或者你只是想让它把输出转储到终端并让滚动到你的终端程序,你可以覆盖它并且根本不使用寻呼机,例如:
git --no-pager log
回答by Clay
In case someone gets this launching bash from Git Extensions, check the setting for Path to linux tools...
. Mine was set to C:\cygwin
. Changing it to C:\Program Files (x86)\Git\bin\
fixed it for me. I didn't have to set the TERM variable to launch bash this way.
如果有人从 Git 扩展中获得这个启动 bash,请检查Path to linux tools...
. 我的设置为C:\cygwin
. 改变它C:\Program Files (x86)\Git\bin\
为我修复它。我不必设置 TERM 变量来以这种方式启动 bash。