首页 > 解决方案 > 如何撤消现有远程存储库中的 git init --bare

问题描述

我错误地在现有的远程存储库中运行了“git init --bare”。Git 说它重新初始化了现有的 git 存储库。有什么办法可以撤销这个动作?

标签: git

解决方案


实际上 'git init --bare' 只会将额外的文件添加到您的存储库中。你可以删除它们。

% cd your-repo
% git status

untracked files:
(use "git add <file>..." to include in what will be committed)

    HEAD
    config
    description
    hooks/
    info/

% git clean -f -d

 Removing HEAD
 Removing branches/
 Removing config
 Removing description
 Removing hooks/
 Removing info/
 Removing objects/
 Removing refs/

您的目录现在像 'git init' 之前一样干净


推荐阅读