Git提示和技巧:在命令提示符下显示分支不工作,并创建git分支功能不起作用的副作用等等 [英] Git Tips and Tricks : Display Branch on Command Prompt not working and created side effects of git branch function not working and many others

查看:119
本文介绍了Git提示和技巧:在命令提示符下显示分支不工作,并创建git分支功能不起作用的副作用等等的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我更新了我的.bashrc文件,正如提示 PS1 ='[\u @ \\ \\ h \ W $(__ git_ps1(%s))] \ $'
但令我惊讶的是现在我的git分支命令不起作用,即使我将它从.bashrc比它也不适合我。



每一次,我使用我的命令提示符我得到 -bash:__git_ps1:command not找到任何指导或建议?



更新:我现在要摆脱它,我该如何实现这是什么?

解决方案

您是否启用了 git bash-completion 函数?您可能已经在您的系统上找到了它们,只是未启用它们。



要确定它们是否处于开启状态,请键入 git 空格 标签 - 如果你得到一个文件列表,你没有完成,如果你得到一个命令列表,提示应该可以正常工作)。



更新:从.bashrc中删除该行后,遇到的问题在重新启动后应该消失贝壳。仅仅重新采集文件将无济于事,因为它不会取消设置提示变量(并且在任何情况下,该变量在您覆盖它之前确实有一个值)。


Just trying to enchance my knowledge of git and use to tips and tricks,

I updated my .bashrc file as suggested in Tip PS1='[\u@\h \W$(__git_ps1 " (%s)")]\$ ' but to my surprise now my git branch command is not working and even if I remove it from .bashrc than also it is not working for me.

Also every time, I use my command prompt I get -bash: __git_ps1: command not found any guidance or suggestions ?

Update : I want to get rid of it now, how can I achieve this ?

解决方案

Have you enabled the git bash-completion functions? You may find them on your system already, just not enabled.

To work out whether they're on or not, type gitSpaceTab -- If you get a list of files, you don't have completion, if you get a list of commands, you do (and your prompt should work).

Update: Once you've removed the line from your .bashrc, the issues you've been experiencing should go away once you've restarted your shell. Merely re-sourcing the file won't help, as it doesn't un-set the prompt variable (and in any case, that variable did have a value before you overrode it).

这篇关于Git提示和技巧:在命令提示符下显示分支不工作,并创建git分支功能不起作用的副作用等等的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆