> For the complete documentation index, see [llms.txt](https://alanmpan.gitbook.io/git-learning/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://alanmpan.gitbook.io/git-learning/ji-chu-pian/32-luo-cang-ku.md).

# 32.裸仓库

创建不含工作树、适合作为共享远程端的裸仓库。

裸仓库（bare repository）没有工作树，其目录本身就是普通仓库中 `.git` 目录对应的内容。它包含对象数据库、引用和配置，但不用于直接编辑项目文件。

因为裸仓库没有工作目录，所以不能像普通的 Git 存储库一样进行日常开发工作。相反，裸仓库主要用于共享代码库或作为远程存储库使用。例如，软件开发团队可能会在内部网络上设置一个裸仓库，允许成员共享代码而无需每次都将代码复制到各自的计算机上。

与非裸仓库相比，裸仓库在协作开发和持续集成方面具有许多优势。由于裸仓库不包含工作目录，因此它们不会与其他分支或提交之间产生冲突，并且可以轻松地与其他远程存储库同步。此外，由于裸仓库不包含工作目录，因此它们的大小更小，可以更快地传输和克隆。

## 创建文件夹

创建文件夹 `git_learning_git`

```powershell
# 查看文件列表
$  ls

    Directory: C:\Users\aku\Desktop
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2023/5/6     2:52                cloned_git_learning
d----            2023/5/6    11:54                git_learning
d----            2023/5/6     2:47                git_learning_git
```

## 创建裸仓库

```powershell
# --bare 用于创建一个裸仓库
$ git clone --bare .\git_learning\ .\git_learning_git\
    Cloning into bare repository '.\git_learning_git'...
        done.
```

## 将裸仓库添加为我们原始仓库的远程仓库

在普通仓库 `git_learning` 中执行

```powershell
cd .\git_learning\
git remote add shared ..\git_learning_git\
```
