【问题标题】:Git bash always says the branch is ((unknown)) in all directoriesGit bash总是说所有目录中的分支都是((未知))
【发布时间】:2013-04-13 18:13:26
【问题描述】:

最近我的 Windows 7 机器上的 GIT 发生了一些非常奇怪的事情。使用 GIT bash,如果我更改到计算机上任何硬盘上的 any 目录,我会看到:

Adam@C-ADAM ~ ((unknown))

~ 根据当前目录而变化。

如果我运行git status,我会得到以下输出:

flashplayerpluginfatal: Not a git repository (or any of the parent directories):
.git

线索必须在flashplayerplugin 中,但是,我在计算机上搜索了此文件夹,但找不到与.git 相关的任何内容。

如果我导航到计算机上的实际 GIT 存储库目录,我会得到:

Adam@C-ADAM /d/WWW/yii-projects/irish-health-pro (flashplayerpluginrefs/heads/ma
ster)

我的另一个猜测是我的$PATH 变量中的某个目录可能包含.git 目录。但是,我已经经历了这些,我找不到任何明显的东西:

$ echo $PATH
/c/Users/Adam/bin:.:/usr/local/bin:/mingw/bin:/bin:/c/Python27/:/c/Python27/Scri
pts:/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/c/Program Files/Comm
on Files/Microsoft Shared/Windows Live:/c/Windows/system32:/c/Windows:/c/Windows
/System32/Wbem:/c/Windows/System32/WindowsPowerShell/v1.0/:/c/EXEs:/c/Program Fi
les (x86)/Microsoft SQL Server/100/Tools/Binn/:/c/Program Files/Microsoft SQL Se
rver/100/Tools/Binn/:/c/Program Files/Microsoft SQL Server/100/DTS/Binn/:/c/xamp
p/apache/bin:/c/xampp/mysql/bin:/c/Program Files (x86)/cwRsync/bin:/c/EXEs:/c/EX
Es/ffmpeg/bin:/c/EXEs/gource:/c/xampp/php:/c/Program Files (x86)/QuickTime/QTSys
tem/:/c/Users/Adam/AppData/Roaming/Python/Scripts:/c/Program Files/Common Files/
Microsoft Shared/Windows Live

我已经重新安装了 GIT,但没有任何区别。

如果我从我得到的任何文件夹中运行 git gui:

有没有人以前见过这样的事情并且知道如何解决?我再也无法在这台计算机上使用 Git,我急于在这个周末完成一些工作!

编辑

根据要求:

$ cd; set -x
++ __git_ps1
++ local pcmode=no
++ local detached=no
++ local 'ps1pc_start=\u@\h:\w '
++ local 'ps1pc_end=\$ '
++ local 'printf_format= (%s)'
++ case "$#" in
++ printf_format=' (%s)'
+++ __gitdir
+++ '[' -z '' ']'
+++ '[' -n '' ']'
+++ '[' -n '' ']'
+++ '[' -d .git ']'
+++ git rev-parse --git-dir
++ local g=flashplayerplugin
++ '[' -z flashplayerplugin ']'
++ local r=
++ local b=
++ '[' -f flashplayerplugin/rebase-merge/interactive ']'
++ '[' -d flashplayerplugin/rebase-merge ']'
++ '[' -d flashplayerplugin/rebase-apply ']'
++ '[' -f flashplayerplugin/MERGE_HEAD ']'
++ '[' -f flashplayerplugin/CHERRY_PICK_HEAD ']'
++ '[' -f flashplayerplugin/BISECT_LOG ']'
+++ git symbolic-ref HEAD
++ b=flashplayerplugin
++ detached=yes
++ b=flashplayerplugin
+++ cut -c1-7 flashplayerplugin/HEAD
++ b=...
++ b=unknown
++ b='(unknown)'
++ local w=
++ local i=
++ local s=
++ local u=
++ local c=
++ local p=
+++ git rev-parse --is-inside-git-dir
++ '[' true = flashplayerplugin ']'
+++ git rev-parse --is-inside-work-tree
++ '[' true = flashplayerplugin ']'
++ local f=
++ '[' no = yes ']'
++ printf -- ' (%s)' '(unknown)'

编辑

根据要求添加更多信息:

Adam@C-ADAM ~ ((unknown))
$ set | grep -F GIT
                            case "${GIT_PS1_DESCRIBE_STYLE-}" in
            b="GIT_DIR!";
            if [ -n "${GIT_PS1_SHOWDIRTYSTATE-}" ]; then
            if [ -n "${GIT_PS1_SHOWSTASHSTATE-}" ]; then
            if [ -n "${GIT_PS1_SHOWUNTRACKEDFILES-}" ]; then
            if [ -n "${GIT_PS1_SHOWUPSTREAM-}" ]; then
        if [ -n "${GIT_PS1_SHOWCOLORHINTS-}" ]; then
            GIT_PS1_SHOWUPSTREAM="$value";
            if [[ -z "${GIT_PS1_SHOWUPSTREAM}" ]]; then
for option in ${GIT_PS1_SHOWUPSTREAM};
                upstream=${GIT_SVN_ID:-git-svn};
        if [ -n "${GIT_DIR-}" ]; then
            test -d "${GIT_DIR-}" || return 1;
            echo "$GIT_DIR";
Adam@C-ADAM ~ ((unknown))
$ cat ~/.gitconfig
[user]
    name = Adam xxxx
    email = adamxxxx@gmail.com
[diff]
    tool = bc3
[difftool "bc3"]
    path = c:/program files (x86)/beyond compare 3/bcomp.exe
[merge]
    tool = bc3
[mergetool "bc3"]
    path = c:/program files (x86)/beyond compare 3/bcomp.exe
Adam@C-ADAM ~ ((unknown))
$ command -V git
git is hashed (/bin/git)
Adam@C-ADAM ~ ((unknown))
$ git --version
flashplayerplugingit version 1.8.1.msysgit.1
Adam@C-ADAM ~ ((unknown))

【问题讨论】:

  • @StevenPenny 我已经编辑了帖子以包含信息。
  • $ file /bin/git sh.exe": file: command not found $ less /bin/git /bin/git: No such file or directory $ ls -la /bin/git -rwxr-xr-x 109 Adam Administ 1371136 Apr 21 17:46 /bin/git $ ldd /bin/git sh.exe": ldd: command not found
  • $ hash -r && command -V git git is /bin/git $ git status flashplayerpluginfatal: 不是 git 存储库(或任何父目录):.git

标签: git fatal-error


【解决方案1】:

一些可能性:

  • 您最近安装了 Rogue Amoeba Airfoil。见:https://stackoverflow.com/a/15598704/712605
  • 您的GIT_DIR 环境变量设置为flashplayerplugin。尝试运行unset GIT_DIR
  • git 调用 shell 函数而不是 git 实用程序。尝试运行unset -f git
  • git 是一个 shell 别名,它正在做一些有趣的事情。尝试运行unalias git
  • git 是一个 shell 脚本,它正在做一些有趣的事情。
  • 文件系统损坏。

如果这些都不起作用,您需要提供更多信息。请使用以下命令的输出更新您的问题:

  • set | grep -F GIT
  • cat ~/.gitconfig
  • command -V git
  • git --version

【讨论】:

  • @Steven 你的任何建议都没有奏效......我已经按照理查德的要求添加了更多信息。 git --version 的输出确实很奇怪...
  • 非常感谢您在聊天会话中帮助我。机翼导致了这个噩梦般的问题......我现在正在联系他们!
【解决方案2】:

建设 Richard’s answer, 我可以通过更改 __git_dir 变量来复制它。对于解决方法,您可以unset此变量。

Steven@STEVEN-PC ~
$ __git_dir=flashplayerplugin

Steven@STEVEN-PC ~ ((unknown))
$ unset __git_dir

Steven@STEVEN-PC ~
$

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-12-11
    • 1970-01-01
    • 2021-02-26
    • 2016-10-24
    • 1970-01-01
    • 2012-01-23
    • 1970-01-01
    • 2023-03-11
    相关资源
    最近更新 更多