初始化 git repo 时 --bare 开关有什么区别?
这个问题与这个问题有些相关: Is it possible to have a git repo inside another git repo
这是摘要:
我有一个 git 存储库,我将其推送到我的网络主机。我分离了该存储库的一个子目录,并将该子目录作为子模块添加回来。现在我将从我的 Web 主机中删除该子目录,在那里创建一个空的 git 存储库,然后将我的子模块推送到那里。所以,我想知道 --bare switch 有什么作用,我需要它吗?
顺便说一句,我是 git 初学者。
This question is somewhat related to this question: Is it possible to have a git repo inside another git repo
Here is the summary:
I had a git repo, which I pushed to my web host. I seperated a subdirectory of that repo, and added that subdirectory back as submodule. Now I am going to remove that subdirectory from my web host, create an empty git repository there, and push my submodule there. So, I was wondering what does --bare switch do, and do I need it.
As a side note, I am git beginner.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
--bare
开关使得存储库没有工作目录;您将无法直接查看任何分支或操作文件。如果没有
--bare
,存储库数据将在$REPO_ROOT/.git
中创建。使用--bare
,存储库数据将在$REPO_ROOT
中创建。当存储库的目的是充当其他存储库的克隆/推送/拉取点时,您通常会使用此选项。
The
--bare
switch makes it so that the repository has no working directory; you will be unable to check out any branches or manipulate files directly.Without
--bare
the repository data will be created in$REPO_ROOT/.git
. With--bare
the repository data will be created in$REPO_ROOT
.You'd typically use this option when the purpose of the repository is to serve as a clone/push/pull point for other repositories.
--bare
开关阻止本地使用和远程使用之间存在冲突的存储库。它使每个人都可以远程使用它,从而避免临时工作文件与已完成的提交的分支和树之间的任何混淆。the
--bare
switch stops the repo having conflicts between local usage and distant usage. It makes everyone use it remotely, and so avoids any confusion between temporary working files and completed committed branches and trees.