lfkid

image


背景

今天,坐我旁边的同事问我一些关于服务器上命令的问题。其中有一个用了特殊参数的 git init 的命令,我也不认识,遂去 Google...
image

bare Git 仓库

定义

A bare Git repository is typically used as a Remote Repository that is sharing a repository among several different people.

什么是 bare Git 仓库呢?简单来说,就是在 Git 服务器上的那个远程 Git 仓库,客户端可以对其进行 push、pull 等操作。
image

创建一个 bare Git 仓库

git init --bare

以上命令会创建一个 bare git 仓库。

bare git 仓库 vs 普通 git 仓库

bare git 仓库与使用 git init 命令创建的普通 git 仓库唯一区别就是:bare git 仓库没有工作目录/工作树,仅仅是包含着了裸仓库数据。

下面我们新建两个文件夹 bare-git-reponormal-git-repo,分别用 git init --baregit init 去初始化看下效果:
image

可以发现,git status 命令在 bare git 仓库中就直接无法使用。而且 bare git 仓库事没有 .git/ 文件夹的,所有配置文件是直接就存在文件夹的根路径下面的。
image

克隆时创建 bare git 仓库

git init --bare 命令类似,我们也可以在使用 git clone 时通过添加 --bare参数来创建一个 bare git 仓库而不是普通的 git 仓库。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-06
  • 2021-12-02
  • 2021-09-22
猜你喜欢
  • 2021-07-07
  • 2021-06-10
  • 2022-12-23
  • 2021-11-15
  • 2021-08-13
相关资源
相似解决方案