Shared Repositories Should Be Bare Repositories

Shared Repositories Should Be Bare Repositories

Commands discussed in this section:

  • git init –bare

Shared Repositories Should Be Bare Repositores

When creating a central repository that will be shared by other users, the repositories should be created with the –bareoption:

gitadmin$ git init --bare project1.git
Initialized empty Git repository in /home/gitadmin/project1.git/

When you create a git repository with the –bare option:

  • There is no working directory created.
  • There is no .git directory is created. Instead, the files normally in the .git directory are placed in the top-level directory where the working directory would normally be.
gitadmin$ cd project1.git
gitadmin$ ls
branches/  config  description  HEAD  hooks/  info/  objects/  refs/

The Bare Git Repository

It is good that shared repositories don’t have working directories!

For example, imagine someone creating a non-bare git repository with both the git repository user and remote users updating the git object database.

The creator of the non-bare git repository would use the git status command one minute and see this:

$ git status
# On branch master
nothing to commit (working directory clean)

The next minute, a remote user could git push a change into the non-bare repository. Then when the creator of the non-bare git repository types git status, git would find a different object database and give different results for this run of git status.

The output of git status should not change unless the user has changed files in the working directory or their object database!

Share Via git clone/pull/fetch/pull

All users editing content from a shared directory need to share the repository via git clone/pull/fetch/push and not by sitting at the working directory and using git statusgit add, and git commit, etc.

If the gitadmin user wants to edit files in the newly created repository, the gitadmin user would also need to use git clone(typed from a different directory) like the rest of the users of the shared repository.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值