• bare Git 仓库是什么?


    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 仓库

    复制代码
    • 1
    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 仓库。👇下面是一个使用 git clone --bare 命令通过克隆 gitignore 仓库在本地创建 git bare 仓库的实例。
    image

    bare git 仓库的命名约定

    从上面的截图中,我们不难发现,这个自动创建的仓库其文件夹名称为 gitignore.git,嗯这也是 bare git 仓库的标准命名方式。

    结论:建议使用 xxxxxx.git 名字来命名 bare git 仓库的文件夹

  • 相关阅读:
    分享一下做一个电商小程序的步骤是什么呢
    基于nodejs+vue学籍管理系统
    AI这门“玄学”为何要从数据平台修起?
    WooCommerce客户数据如何存储在数据库中
    Mybatis笔记一
    正则表达式完整入门教程,含在线练习
    基于Spring、SpringMVC、MyBatis的外卖点餐网站
    「数据结构详解·四」队列
    Cortex-M架构系统定时器阻塞和非阻塞延时
    excel补充操作技能1
  • 原文地址:https://www.cnblogs.com/lfkid/p/what-is-bare-git-repository.html