> 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/git/35.-tuo-guan-git-cang-ku.md).

# 35.托管Git仓库

## 实验

设置 Git 守护进程 (Git Daemon) 共享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

# 开启守护进程
$ git daemon --verbose --export-all --base-path=. --enable=receive-pack --reuseaddr
[6608] Ready to rumble
```

新开一个窗口访问

```powershell
# 查看当前路径
$ pwd
Path
----
C:\Users\aku\Desktop

# 执行克隆
$ git clone git://localhost/git_learning net_git
Cloning into 'net_git'...
remote: Enumerating objects: 38, done.
remote: Counting objects: 100% (38/38), done.
remote: Compressing objects: 100% (25/25), done.
remote: Total 38 (delta 1), reused 0 (delta 0), pack-reused 0
Receiving objects: 100% (38/38), done.
Resolving deltas: 100% (1/1), done.
```

查看新克隆库文件内容

```powershell
$ ls .\net_git\
Directory: C:\Users\aku\Desktop\net_git

Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d----            2023/5/6    12:06                lab
-a---            2023/5/6    12:06             27 .gitignore
-a---            2023/5/6    12:06             59 README.md
```

## Git 托管的其它信息

1. 使用 Git 托管服务 有许多受信任的 Git 托管服务可供选择，例如 GitHub、GitLab 和 Bitbucket。这些服务提供了一个 Web 界面，用于管理存储库、团队和权限，并允许您轻松地与其他人共享代码。您可以使用这些服务中的任何一个来托管您的 Git 存储库，并根据需要设置公共或私有访问权限。
2. 搭建自己的 Git 服务器 如果您希望完全控制自己的 Git 存储库，那么您可以搭建自己的 Git 服务器。有几种方法可以实现这一点，包括使用 Gitosis 或 Gitolite 这样的工具来设置服务器，也可以直接在您的服务器上安装 Git 并手动设置存储库权限。无论哪种方法，都需要一定的技术知识和配置。
3. 在云端虚拟机中托管 Git 存储库 如果您希望在云端虚拟机中托管 Git 存储库，那么您可以使用 Amazon EC2、Microsoft Azure 或 Google Cloud Platform 等云计算平台来部署您的服务器。这些服务提供了虚拟机、存储和网络基础架构，使您能够快速和轻松地部署您的 Git 存储库，并根据需要进行扩展。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://alanmpan.gitbook.io/git-learning/git/35.-tuo-guan-git-cang-ku.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
