建立实验室来试验 GIT
我是一名 Linux 新手(大约 6 个月)。
我使用 Git 已经有一段时间了,现在我想开始学习更高级的东西。我想学习的是处理/管理遥控器的各种方法。
所以我的问题是——如何在本地设置“远程”?是否可以创建两个文件夹,例如:
/home/my_user/git_experiment/remote_branch
/home/my_user/git_experiment/local_branch
并将 local_branch
文件夹设置为跟踪 remote_branch
文件夹,就像 remote_branch
是 GitHub 上的存储库一样?
I'm a newbie (like 6 months) Linux user.
I'm using Git for quite a while, and now I'd like to start learning more advanced stuff. What I'd like to learn is a variety of ways to handle/manage remotes.
So my question is — how can I setup a "remote" locally? Is it possible to create two folders, for example:
/home/my_user/git_experiment/remote_branch
/home/my_user/git_experiment/local_branch
and set local_branch
folder to track remote_branch
folder just like if remote_branch
would be a repo on GitHub?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
遥控器只是一个克隆,您可以通过某种方式访问它。通常它是通过 git 协议或 http(用于读取)和 ssh 或 https(用于写入)进行访问,但文件系统访问也同样有效。您需要做的就是克隆您的存储库:
原始远程将自动在project2中设置,指向项目,就像您习惯的那样。您可以在项目中添加相应的远程,指向项目2,然后尝试执行您想要执行的任何获取和拉取操作。
如果您想尝试推送,请确保创建一个裸克隆来推送:
我不确定为什么将它们命名为“local_brach”和“remote_brach”(这是否意味着“分支”?)。这些不是分支机构。他们是克隆人;他们可以有自己的全套分支,可能还有一些相应的分支。
A remote is just a clone which you have some way to access. Commonly it's accessed via the git protocol or http (for reading) and ssh or https (for writing), but filesystem access works just as well. All you need to do is clone your repo:
The origin remote will automatically be set up in project2, pointing to project, just like you're used to. You could add a corresponding remote in project, pointing to project2, and try out whatever fetching and pulling you want to do.
If you want to try out pushing, make sure you make a bare clone to push into:
I'm not sure why you're naming them "local_brach" and "remote_brach" (is that meant to say "branch"?). These aren't branches. They're clones; they can have their own full sets of branches, probably with some corresponding.
有可能,
git remote
的
参数可以只是一个路径:It is possible, the
<url>
parameter togit remote
can just be a path: