【问题标题】:Git - did init bare in wrong directoryGit - 在错误的目录中进行了初始化
【发布时间】:2012-04-25 11:34:58
【问题描述】:

我在错误的目录(在服务器中)中运行了git --bare init。我在该目录中看到了文件分支、配置、deps 等。我该如何撤消它?

【问题讨论】:

    标签: git undo git-bare


    【解决方案1】:

    由于您执行了“--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/
    

    要撤消此操作,只需执行:

    rm -rf HEAD config hooks objects branches description info refs
    

    当然,如果您已经有使用这些名称的文件和目录,请小心。

    【讨论】:

    • s/discription/description/ 我无法编辑,因为它只有一个字母。
    【解决方案2】:

    如果您在之前未设置为 git 存储库的目录上执行此操作,则只需删除 .git 文件夹(假设您使用的是 linux):

    rm -rf .git
    

    否则,如果目录已经包含存储库(.git 目录),那么 git init 将不起作用(即 git log 将在 git init 之前和之后显示相同的提交)。

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-07-11
    • 1970-01-01
    • 2014-06-22
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多