使用git在/ opt /中为所有用户存储存储库?

时间:2016-07-19 21:09:51

标签: linux git local-storage

我有几个用户在同一个linux机器上,有几个人远程访问,我们正在开发一个软件项目。

如何将主存储库保存在/ opt中(例如/ opt / GitRepo / project).. 并让其他人在他们的本地/家庭/用户目录中拥有一个品牌?

我试图克隆目录,但在尝试推迟更改时遇到错误:

cd /home/user1/localGit/    
git clone /opt/GitRepo/project

我在该本地副本中进行更改后尝试执行git push

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

1 个答案:

答案 0 :(得分:2)

/opt/GitRepo/project中的共享存储库应该是一个“裸”存储库。这实际上意味着它只包含您在.git目录中通常会找到的内容,并且没有工作树;请参阅here进行讨论。

您可以像这样创建一个裸克隆:

git clone --bare <address> <target>

或者初始化一个空的裸存储库:

git init --bare