Git 自动完成要求输入密码,不知道为什么

Bob*_*bby 7 bash git 12.10

我遇到了使用 git 自动完成的问题......我使用的是 ubuntu 12.10,当我执行以下按键时

g i t Space Bar Tab

我看到了错误

不会分配伪终端,因为 stdin 不是终端。

并提示输入密码。我不清楚如何解决此错误,我尝试卸载并重新安装 git 无济于事。

有错误的终端截图: 有错误的终端

/root/.bashrc&之间的区别~/.bashrc

3a4
> export JAVA_HOME="/usr/lib/jvm/java-6-sun"
21a23,25
> JAVA_HOME="/usr/lib/jvm/java-6-sun"
> export JAVA_HOME
> 
51a56,63
> git_prompt()
> {
>   git_branch=$(git branch 2>/dev/null | sed -n '/^\*/s/^\* //p')
>   if [ -n "$git_branch" ]; then
>       echo "($git_branch)"
>   fi
> }
> 
53c65
<     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
---
>     PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(git_prompt)\$ '
55c67
<     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ '
---
>     PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(git_prompt)\$ '
84a97,100
> # Add an "alert" alias for long running commands.  Use like so:
> #   sleep 10; alert
> alias alert='notify-send --urgency=low -i "$([ $? = 0 ] && echo terminal || echo error)" "$(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert$//'\'')"'
> 
97,99c113,115
< #if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
< #    . /etc/bash_completion
< #fi
---
> if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
>     . /etc/bash_completion
> fi
Run Code Online (Sandbox Code Playgroud)

小智 4

在评论中讨论了与可能的别名和异常环境变量有关的可能解决方案后.bashrc,我们得出的结论是问题出在文件中.bash_aliases,其中包含以下行:

alias test="ssh username@some.server.com"
Run Code Online (Sandbox Code Playgroud)

这是合乎逻辑的,因为我测试了.bashrc所提供的文件,它工作得很好,没有发生错误,所以问题必须出在另一个文件中。

这证实了我最初的怀疑,即该问题与 相关ssh,因为错误:

Pseudo-terminal will not be allocated because stdin is not a terminal
Run Code Online (Sandbox Code Playgroud)

ssh仅在涉及时才会发生,如Ubuntu 论坛Stackoverflow 中所述。因此看起来 bash 自动完成或 git 没有 bug,所以问题就被发现了。