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

标签 linux git local-storage

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

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

我尝试克隆目录,但在尝试推回更改时出现错误:

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/

最佳答案

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

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

git clone --bare <address> <target>

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

git init --bare

关于linux - 使用 git 为所有用户将存储库存储在/opt/中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38468580/

相关文章:

linux - 为什么 nautilus 会提前读取目录?

git - 释放不必要的Docker镜像的空间

c# - 拒绝为 C# (Unity) 推送基于 Git 提交代码的样式检查?

javascript - 保存并使用 chrome.sync.storage.get() 中的值

sqlite - LocalStorage或SQLite数据库?

php - 如何在 Earthlink Linux 服务器上安装 PHP?

linux - logrotate:删除超过 n 天的 tomcat/jboss 日志

Git:我的本地存储库在哪里? (没有 .git 目录)

visual-studio - NgxLocalStorage 不检索值

linux - fish shell : How can I customize the colors for the autocomplete feature?