# 32.裸仓库

裸仓库（bare repository）是一个没有工作目录的 Git 存储库。通常来说，Git 存储库会包含一个 ".git" 目录和一个工作目录，该目录中保存了项目文件的副本以及对它们进行的修改。而裸仓库则只包含 ".git" 目录，其中存储着版本控制所需要的所有文件，包括对象数据库、索引和配置文件，但不包含实际的项目文件。

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

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

## 创建文件夹

创建文件夹 `git_learning_git`

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

    Directory: C:\Users\aku\Desktop
Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2023/5/6     2:52                cloned_git_learnnig
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_git` 中执行

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alanmpan.gitbook.io/git-learning/git/32.-luo-cang-ku.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
