如何与其他用户共享工作存储库(推/拉)?

时间:2015-02-25 04:44:21

标签: git git-clone git-init

我通过运行:

从Assembla克隆了一个Git存储库
git clone git@git.assembla.com:[my_project].git

我如何与其他用户共享我的工作存储库(位于/usr/local/project),以便他们可以直接从/拉出并推送到我的工作存储库?

我已经尝试通过运行:

从我的工作存储库初始化Git存储库
git init

git init --bare

然后我使用另一台计算机将提交推送到我的工作存储库,但是我收到错误:

Pushing to /usr/local/project/
remote: error: refusing to update checked out branch: refs/heads/master[K
remote: error: By default, updating the current branch in a non-bare repository[K
remote: error: is denied, because it will make the index and work tree inconsistent[K
remote: error: with what you pushed, and will require 'git reset --hard' to match[K
remote: error: the work tree to HEAD.[K
remote: error: [K
remote: error: You can set 'receive.denyCurrentBranch' configuration variable to[K
remote: error: 'ignore' or 'warn' in the remote repository to allow pushing into[K
remote: error: its current branch; however, this is not recommended unless you[K
remote: error: arranged to update its work tree to match what you pushed in some[K
remote: error: other way.[K
remote: error: [K
remote: error: To squelch this message and still keep the default behaviour, set[K
remote: error: 'receive.denyCurrentBranch' configuration variable to 'refuse'.[K
To /usr/local/project/
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '/usr/local/project'

2 个答案:

答案 0 :(得分:2)

这似乎与我曾经遇到过的问题非常相关:

error: refusing to update checked out branch: refs/heads/master

我读过这是因为分支处于非裸状态。如果有人推进这个分支,它将覆盖签出副本的现有状态。

一般解决方案是使用裸存储库,该存储库由以下内容完成:

git init --bare

另一种可能性是使用分支

git push fails: `refusing to update checked out branch: refs/heads/master`还给了我一些关于如何解决它的深刻见解!

祝你好运! :)

乔伊

答案 1 :(得分:1)

如果您要在多台计算机之间进行协作甚至共享,则必须设置远程仓库。通常人们使用诸如Github或Unfuddle之类的服务来托管远程回购。但是,您也可以自己设置。官方Git documentation会帮助你。