在本地计算机上设置 git 存储库
如何在本地系统上设置 git 存储库? (我在windoze盒子上)
这是我想要实现的设置:(一切都在我的本地计算机上)
- 主机文件夹(其作用类似于中央存储库)
- 客户端文件夹
我想在客户端文件夹中执行所有开发操作。完成后,我想将其推送到主机文件夹。
这就是我所做的:(在 Windows 上使用 git bash)
- cd d:/adinsert
- mkdir host
- cd 主机
- git 初始化
cd c:/
- mkdir 客户端
- cd 客户端
- git 初始化
- git 远程添加源 d:/host // 在client文件夹中添加一些文件并提交
- git push origin master
当我将东西推送到 origin 时,git 会吐出很多远程错误。然而,当我让我的主机成为裸机 git 时,它会成功推送。
我不明白常规 git 和裸 git 之间的区别。从手册中,我了解到的是,裸 git 用于存储增量以及当您不想存储原始文件时。但是,我想将文件存储在主机中。我怎样才能做到这一点?
How can I setup a git repository on a local system ? (I am on a windoze box)
This is the setup I am trying to achieve: (everything is on my local machine)
- host folder (which acts like central repository)
- client folder
I want to do all my dev in the client folder. Once I am done, I'd like to push it to the host folder.
This is what I've done: (using git bash on windows)
- cd d:/adinsert
- mkdir host
- cd host
- git init
cd c:/
- mkdir client
- cd client
- git init
- git remote add origin d:/host
// Added some files in client folder and commited them - git push origin master
When I push stuff to origin, git spits a lot of remote errors. However, when I make my host a bare git, it pushes successfully.
I don't understand the difference between regular git and bare git. From the manual, all I understood was, bare git is used for storing deltas and when you don't want to store original files. However, I'd like to store the files in host. How can I do that ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
“常规 git”和“裸 git”之间的区别在于裸存储库没有有工作目录。您永远不应该推送到常规 git 存储库,因为您可能会遇到难以恢复的问题。始终推入裸存储库。
如果您希望有一个“主机”来显示文件的副本,则设置第三个存储库,从主机克隆。每当您想要更新主机文件时:
git Push
来更新主存储库git pull
从您的主机目录中从源拉取您甚至可以设置裸存储库上的提交后挂钩自动执行第二步。
The difference between a "regular git" and a "bare git" is that a bare repository does not have a working directory. You should never push into a regular git repository, as you may run into problems that are hard to recover from. Always push into a bare repository.
If you want to have a "host" where copies of your files do appear, then set up a third repository, cloning from the host one. Whenever you want to update the host files:
git push
from your working directory to update the main repositorygit pull
from your host directory to pull from the originYou can even set up a post-commit hook on the bare repository to automatically do the second step.
在您的
client
目录中,您会注意到一个.git
目录。bare
版本基本上就是.git
目录内容,没有工作副本。最简单的方法是克隆它(而不是尝试设置另一个存储库):
从 c:/ 调用:
这表示克隆“主机”存储库并将其存储在名为“客户端”的文件夹下。
In your
client
directory you have will notice a.git
directory. Abare
version is basically just that.git
directory contents without a working copy.Easiest thing to do would be to clone it (vs trying to setup another repository):
From c:/ call:
This says clone the 'host' repo and store it under a folder called 'client'.
不要在客户端文件夹中创建新的 git 存储库,而是克隆主机存储库
Don't create a new git repo in the client folder, clone the host repo