centos5 git 共享文件夹

发布于 2024-11-28 01:16:41 字数 1864 浏览 1 评论 0原文

我是 git 新手,遇到了问题 我在 git 系统上推送数据时遇到问题。 我安装了 git 和 gitolite,但是当我调用:“git Push origin master”时,它给了我这个错误:

Counting objects: 12, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 1.47 KiB, done.
Total 12 (delta 1), reused 5 (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 [email protected]:gitolite-admin
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '[email protected]:gitolite-admin'

我按照本教程安装 gitolite: gitolink 一切都按我应该的方式进行,但在最后一步。当我执行命令时,我遗憾地收到此错误,

任何人都可以告诉我该怎么做或如何解决此问题? 已经试过了: git config --bool core.bare true 更改分支(以便它(master)不被使用)

i'm new to git and i'm having a problem
i have a problem at pushing data at my git system.
i installed git and gitolite but when i call: "git push origin master" it gives me this error:

Counting objects: 12, done.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (12/12), 1.47 KiB, done.
Total 12 (delta 1), reused 5 (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 [email protected]:gitolite-admin
 ! [remote rejected] master -> master (branch is currently checked out)
error: failed to push some refs to '[email protected]:gitolite-admin'

i followed this tutorial installing gitolite: gitolink
everything worked as i should be but at the very last step. When i execute the command i sadly got this error

can anyone tell me what to do or how to fix this?
already thried :
git config --bool core.bare true
changing the branch (so that it(master) isn't in use)

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

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

发布评论

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

评论(1

眼趣 2024-12-05 01:16:41

基本问题是您正在尝试推送到“非裸”git 存储库。虽然这是可能的,但许多文档和书籍并没有明确表明不建议这样做。

因此,虽然 git 是一个去中心化/多主 scm,但在实践中,您往往拥有的是“主”或“中央”存储库,您可以从这些存储库中克隆并推送到这些存储库,然后充当“规范”存储库,以及从“主库”克隆的工作存储库(例如在您的笔记本电脑上),您可以拉取并从中推送。这些“主”存储库应该使用 --bare 创建:

server$ cd ; mkdir git
server$ git clone --bare /home/user/foo /home/user/git/foo.git

完成此操作后,您将能够从笔记本电脑上推送:

laptop$ cd foo
laptop$ git remote -v
laptop$ origin user@server:/home/user/git/foo.git (fetch)
laptop$ origin user@server:/home/user/git/foo.git (push)
laptop$ git push origin master

您也可以在服务器上执行此操作:

git config --global receive.denyCurrentBranch "ignore"

但在您更好地理解之前我不会这样做git 是如何工作的。

The basic problem is that you're trying to push to a "none-bare" git repository. Whilst this is possible, a lot of the documentation and books don't make it clear that this isn't recommended.

So while git is a decentralised/many-master scm, in practice what you tend to have is "master" or "central" repositories that you clone from and push to and serve as the "canonical" repo, and work repos (eg on your laptop) that you cloned from a "master" that you pull to and push from. These "master" repositories should be created with --bare:

server$ cd ; mkdir git
server$ git clone --bare /home/user/foo /home/user/git/foo.git

Once you've done this, you'll be able to push from your laptop:

laptop$ cd foo
laptop$ git remote -v
laptop$ origin user@server:/home/user/git/foo.git (fetch)
laptop$ origin user@server:/home/user/git/foo.git (push)
laptop$ git push origin master

You could also do on the server:

git config --global receive.denyCurrentBranch "ignore"

But I wouldn't do this until you understand better how git works.

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