--bare选项等于Git中的core.bare配置吗? [英] Is --bare option equal to core.bare config in Git?
问题描述
我想在服务器上创建一个git repo,以在推送后更新我的网站.所有教程的第一步(例如: http://developertheory.com/how-to-auto-deploy-apps-after-git-push/),我找到的是以下命令:
git init --bare
在接下来的步骤中,我应该输入以下命令:
git config core.worktree /path/to/git/deploy
git config core.bare false
git config receive.denycurrentbranch ignore
第二个命令(git config core.bare false
)将存储库设置为非裸露.为什么我们将存储库初始化为裸机,然后将其设置为非裸机?!
我怀疑本教程使用git init --bare
作为干净"方式创建无法与实际文件混合的空存储库:
即使在重新配置为非裸露之后,这样的repo也将直接包含.git
常规内容.
为了使git checkout
(在挂钩中)起作用,您需要一个非裸仓库,因为您只能在非裸仓库中签出一个分支(按照定义,裸仓库没有工作树). /p>
不过,我不建议部署该方法,我更喜欢:
- 保留该仓库以进行推送
- 设置非公开的第二回购
- 在第一个(裸)存储库上添加一个后接收挂钩,以便第二个存储库从第一个刚刚接收的存储库中拉出.
例如参见:
I want to create a git repo on my server to update my website after pushing. The first step of all tutorials(such as this: http://developertheory.com/how-to-auto-deploy-apps-after-git-push/) I found, is this command:
git init --bare
In the next steps I should enter the following commands:
git config core.worktree /path/to/git/deploy
git config core.bare false
git config receive.denycurrentbranch ignore
the second command (git config core.bare false
) set the repo to non-bare. Why do we init the repo as bare and then set it to non-bare?!
I suspect this tutorial uses git init --bare
as a "clean" way to create an empty repo which cannot be mixed with the actual files:
Such a repo will contain directly the .git
usual content, even after being re-configure as non-bare.
You need a non-bare repo in order for the git checkout
(in the hook) to work, since you can only checkout a branch in a non-bare repo (a bare one, by definition, has no working tree).
I wouldn't recommend that method for deployment though, and I prefer:
- keeping that repo bare in order to push to it
- setting up a second repo, non-bare
- adding a post-receive hook on the first (bare) repo in order for the second one to pull from what the first one just received.
See for instance:
这篇关于--bare选项等于Git中的core.bare配置吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!