Git,如何将裸仓库更改为共享仓库?

发布于 2024-12-27 07:14:30 字数 248 浏览 5 评论 0原文

这就是我设置项目的方式:

git init --bare

后来我了解到,如果你想与多个用户一起开发一个项目,我应该这样做:

git init --bare --shared

现在我尝试像那样工作,幸运的是我们还处于开始阶段,所以我可以再次设置git。我仍然想知道当你正在进行一个项目时你不能这样做。 有没有一种方法可以将裸存储库更改为共享存储库?

So this is how I set up my project:

git init --bare

Later I learned that if you want to work on a project with multiple users this is how I should have done it:

git init --bare --shared

Now I tried to work like that and luckily we are in the beginning so I could set up git again. I still wonder though when you're in the middle of a project you can't do that.
Is there a way that i can change a bare repo to a shared one?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

乄_柒ぐ汐 2025-01-03 07:14:30

由于 --shared 选项只是将存储库中所有内容的权限设置为组可写,您可以稍后手动执行此操作:

$ chmod -R g+w the/repo/path

另外,

sharedrepository = 1

[core] 部分下 添加.git/config。共享存储库还默认定义了以下接收选项(您可能希望也可能不希望):

[receive]
    denyNonFastforwards = true

注意:为了决定是否需要 DenyNonFastforwards:此选项意味着共享存储库中永远不会发生合并,这反过来又意味着共享存储库上永远不会发生合并冲突。相反,推送会被拒绝,迫使用户在本地存储库中进行合并,这样更容易修复,并且不会干扰其他人对共享存储库的使用。

Since the --shared option just sets the permissions on everything in the repository to group-writable you could do this manually later:

$ chmod -R g+w the/repo/path

Plus, add

sharedrepository = 1

under the [core] section in .git/config. Shared repos also have the following receive option defined by default (which you may or may not want):

[receive]
    denyNonFastforwards = true

Note: In order to decide whether you want denyNonFastforwards: This option means a merge never happens in the shared repository, which, in turn, means there is never a merge conflict on the shared repository. Instead the push is rejected forcing the user to do the merge in their local repository where it's much easier to fix and where it doesn't interfere with other people's use of the shared repo.

白龙吟 2025-01-03 07:14:30

除了 chmod -R g+w 之外,您还需要编辑 (.git/)config 并设置 core.sharedRepository = ...。对于...,有一些值,如 git-init(1) 中所述。

Besides chmod -R g+w, you also need to edit (.git/)config and set core.sharedRepository = .... For ..., there are a handful of values, described in git-init(1).

So要识趣 2025-01-03 07:14:30

如果您尝试共享现有存储库,可能会有许多不同的用户提交。

1.如果您有超级用户权限,您可以使用第二步自行更改所有权限,否则您将需要询问所有使用其用户创建对象的用户,使用以下命令来了解谁它们是:

$ ls -la | awk '{print $3}' | sort -u 
<your user_name>
<his user_name>

2.现在,您和所有文件的所有者用户必须更改这些文件的权限,执行:

$ chmod -R 774 .

3.之后,您将需要添加一个新属性,该属性相当于为新存储库完成的 --shared=group ,根据对于文档,这使得存储库组可写,执行:

$ git config core.sharedRepository group

Probably if you try to share an existent repository, you may have lots of different users commits.

1.If you have super user permission, you can go forward and change all permissions by yourself using the step two, in any-other case you will need to ask all users with objects created with their users, use the following command to know who they are:

$ ls -la | awk '{print $3}' | sort -u 
<your user_name>
<his user_name>

2.Now you and all file's owner users will have to change those files permission, doing:

$ chmod -R 774 .

3.After that you will need to add a new property that is equivalent to --shared=group done for the new repository, according to the documentation, this make the repository group-writable, do it executing:

$ git config core.sharedRepository group
谜泪 2025-01-03 07:14:30

如果您尝试从其所在的主机共享存储库,则必须执行其他配置步骤(ssh 内容)。

http://shapeshed.com/setting_up_git_for_multiple_developers/

http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/

If you're trying to share the repository off of the the host it is on, there are additional configuration steps you have to make (ssh stuff).

http://shapeshed.com/setting_up_git_for_multiple_developers/

http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文