Git - 在init目录中初始化了

500*_*865 11 git undo git-bare

git --bare init在一个错误的目录(在服务器中)运行.我在该目录中看到文件branches,config,deps等..如何撤消它?

GoZ*_*ner 29

由于您执行了'--bare'初始化,因此没有.git目录 - 而.git目录的正常内容直接在父目录中.例如,您执行'git init --bare'的位置如下所示:

$ git --bare init
Initialized empty Git repository in /Users/ebg/test/foo/
$ ls
HEAD        config      hooks/      objects/
branches/   description info/       refs/
Run Code Online (Sandbox Code Playgroud)

撤消这个只是执行:

rm -rf HEAD config hooks objects branches description info refs
Run Code Online (Sandbox Code Playgroud)

当然,如果你已经有了那些名字的文件和目录,请小心.


Blu*_*ict 5

如果你在以前没有设置为git存储库的目录上做过,你可以删除.git文件夹(假设你使用的是linux):

rm -rf .git
Run Code Online (Sandbox Code Playgroud)

否则,如果目录已经包含了存储库(.git目录),那么git init将没有任何效果(即git log将在git init之前和之后显示相同的提交).

  • 更新:GoZoner的答案(http://stackoverflow.com/a/10135410/754042)实际上是正确的答案,我的答案仅适用于没有--bare开关运行git init的情况. (4认同)