Git,如何将裸更改为共享存储库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/8883081/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git, How to change a bare to a shared repo?
提问by bottleboot
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?
现在我尝试这样工作,幸运的是我们才刚刚开始,所以我可以再次设置 git。我仍然想知道当你在一个项目的中间时你不能这样做。有没有办法可以将裸存储库更改为共享存储库?
回答by miku
Since the --shared
option just sets the permissions on everything in the repository to group-writable you could do this manually later:
由于该--shared
选项只是将存储库中所有内容的权限设置为 group-writable,您可以稍后手动执行此操作:
$ 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 optiondefined by default (which you may or may not want):
在 中的[core]
部分下.git/config
。共享存储库还默认定义了以下接收选项(您可能需要也可能不需要):
[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.
注意:为了决定是否需要 denyNonFastforwards:此选项意味着共享存储库中永远不会发生合并,这反过来意味着共享存储库上永远不会发生合并冲突。相反,推送被拒绝,迫使用户在他们的本地存储库中进行合并,在那里更容易修复并且不会干扰其他人对共享存储库的使用。
回答by j?rgensen
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).
除了 chmod -R g+w,您还需要编辑(.git/)config
和设置core.sharedRepository = ...
. 对于...,有一些值,在 git-init(1) 中进行了描述。
回答by helmedeiros
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:
1.如果你有超级用户权限,你可以继续使用第二步自己更改所有权限,在任何其他情况下,你需要询问所有用户创建的对象,使用以下命令知道是谁他们是:
$ ls -la | awk '{print }' | 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:
2.现在您和所有文件的所有者用户都必须更改这些文件的权限,请执行以下操作:
$ 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:
3.之后,您需要为新存储库添加一个等效于 --shared=group done 的新属性,根据文档,这使存储库可组写,执行以下操作:
$ git config core.sharedRepository group
回答by helmedeiros
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).
如果您尝试从它所在的主机上共享存储库,则必须执行其他配置步骤(ssh 内容)。
http://shapeshed.com/setting_up_git_for_multiple_developers/
http://shapeshed.com/setting_up_git_for_multiple_developers/
http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/
http://www.jedi.be/blog/2009/05/06/8-ways-to-share-your-git-repository/