解决方案:终于实现了问题.愚蠢的用户错误.忘了先在新项目目录中运行’git init’.因此,在没有git repo的目录中运行’git add.’,’git remote add origin repo.git'(甚至是拼写错误’git add origin repo.git’)将恢复为全局应用命令,因此所有git状态结果中的父目录和其他目录.
我已经使用git一段时间了,从来没有遇到过这个问题,不知道发生了什么.简而言之,使用’git remote add origin git@github.com …’在我的整个文件系统中创建一个全局远程,而不是仅在当前目录中创建一个本地远程.它甚至会覆盖其他横向目录中的遥控器.
这段代码胜过千言万语,任何人都知道这里发生了什么:
prompt:~/bin/Projects$ls -al
total 56
drwxr-xr-x 15 kurtosis kurtosis 4096 2011-09-09 21:35 .
drwxr-xr-x 26 kurtosis kurtosis 4096 2011-09-09 21:35 ..
drwxr-xr-x 5 kurtosis kurtosis 4096 2011-06-16 13:42 byrongibson.com
drwxr-xr-x 5 kurtosis kurtosis 4096 2011-06-16 13:44 byrongibson.github.com
drwxr-xr-x 3 kurtosis kurtosis 4096 2011-09-09 21:33 kNow.io
drwxr-xr-x 3 kurtosis kurtosis 4096 2011-06-16 13:45 problem-sets
drwxr-xr-x 2 kurtosis kurtosis 4096 2011-07-18 20:11 vim~
prompt:~/bin/Projects$git remote -v
prompt:~/bin/Projects$cd kNow.io/
prompt:~/bin/Projects/kNow.io$ls -al
total 16
drwxr-xr-x 3 kurtosis kurtosis 4096 2011-09-09 21:33 .
drwxr-xr-x 15 kurtosis kurtosis 4096 2011-09-09 21:35 ..
-rw-r--r-- 1 kurtosis kurtosis 7 2011-09-09 21:27 README.md
drwxr-xr-x 2 kurtosis kurtosis 4096 2011-09-09 21:27 vim~
prompt:~/bin/Projects/kNow.io$git remote -v
prompt:~/bin/Projects/kNow.io$git remote add origin git@github.com:byrongibson/kNow.io.git
prompt:~/bin/Projects/kNow.io$git remote -v
origin git@github.com:byrongibson/kNow.io.git (fetch)
origin git@github.com:byrongibson/kNow.io.git (push)
prompt:~/bin/Projects/kNow.io$cd ..
prompt:~/bin/Projects$git remote -v
origin git@github.com:byrongibson/kNow.io.git (fetch)
origin git@github.com:byrongibson/kNow.io.git (push)
prompt:~/bin/Projects$cd ~
prompt:~$git remote -v
origin git@github.com:byrongibson/kNow.io.git (fetch)
origin git@github.com:byrongibson/kNow.io.git (push)
prompt:~$cd bin/Github
prompt:~/bin/Github$git remote -v
origin git@github.com:byrongibson/kNow.io.git (fetch)
origin git@github.com:byrongibson/kNow.io.git (push)
prompt:~/bin/Github$
Update1:这个问题神秘地消失了.不知道我做了什么或为什么.如果我搞清楚,会更新答案.
Update2:我用另一个存储库再次做到了.这次我认为是因为,当我设置存储库并添加远程源时,我做了一个错字并做了这个:
> git add origin git@github.com/.../repo.git
例如,我忘记了’遥远’.这将〜/ .git / config中的全局原点设置为:
[remote "origin"]
url = git@github.com/.../repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
从配置中删除它会删除全局原点,但不幸的是当我回到我的新仓库并使用’git add.’时,它不仅会添加我的仓库中的每个文件和目录,而且显然我的仓库之外的所有内容都不在我的全局中.gitignore:
prompt:~/bin/Projects/Haskell/Courses/Stanford$git remote -v
prompt:>~/bin/Projects/Haskell/Courses/Stanford$git remote add origin git@github.com:byrongibson/stanford-fall2011-cs240h.git
prompt:>~/bin/Projects/Haskell/Courses/Stanford$git remote -v
origin git@github.com:byrongibson/stanford-fall2011-cs240h.git (fetch)
origin git@github.com:byrongibson/stanford-fall2011-cs240h.git (push)
prompt:>~/bin/Projects/Haskell/Courses/Stanford$git add .
prompt:>~/bin/Projects/Haskell/Courses/Stanford$ls -al
total 12
drwxr-xr-x 3 byron byron 4096 2011-09-26 18:19 ./
drwxr-xr-x 3 byron byron 4096 2011-09-26 18:19 ../
drwxr-xr-x 2 byron byron 4096 2011-09-26 18:09 Lectures/
prompt:>~/bin/Projects/Haskell/Courses/Stanford$git status
# On branch master
# Changes to be committed:
# (use "git reset HEAD <file>..." to unstage)
#
# new file: Lectures/basics1-slides.html
# new file: Lectures/basics1.html
# new file: Lectures/basics1.md
# new file: ../../../../btccx/btc.cx/README
# new file: ../../../../btccx/btc.cx/README.md
#
# Changed but not updated:
# (use "git add/rm <file>..." to update what will be committed)
# (use "git checkout -- <file>..." to discard changes in working directory)
#
# modified: ../../../../../.gitconfig
# modified: ../../../../../.profile
# modified: ../../../../../Downloads/Keys/chromiumppa_key.html
# modified: ../../../../../Downloads/Keys/chromiumppa_key.pub
# modified: ../../../../../Downloads/Keys/linux_signing_key.pub
# modified: ../../../../../Downloads/Keys/tor-key-install.sh
# deleted: ../../../../btccx/btc.cx/README
# deleted: ../../../../btccx/btc.cx/README.md
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# ../../../../../.FBReader/
# ../../../../../.ICEauthority
# ../../../../../.Skype/
# ../../../../../.SpiderOak/
.
.
.
# ../../../../../Downloads/xmonad-ubuntu.html
# ../../../../../Downloads/xmonad-ubuntu_files/
# ../../../../../DropBox/
# ../../../../../Music/
# ../../../../../Pictures/
# ../../../../../SpiderOak/
# ../../../../../Ubuntu One/
# ../../../../../Videos/
# ../../../../Archive/
# ../../../../Clients/
# ../../../../CryptoCurrency/
# ../../../../Databases/
# ../../../../Git/
# ../../../../Go/
# ../../../../Google/
# ../../../../Hosts/
# ../../../99-scala-problems/
# ../../LYaH/
# ../../RWH/
解决方法:
如果在git存储库外运行git remote -v,通常会出现以下错误:
$git remote -v
fatal: Not a git repository (or any of the parent directories): .git
我猜想发生的事情是你在某个时刻不小心在主目录中运行了git init,这可以解释你所看到的内容.如果您运行:
git rev-parse --show-toplevel
那应该会向您展示您实际所在的git存储库的顶级.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。