Git 在两个本地存储库之间拉取更改
我有同一个远程存储库的两个克隆。我对一个本地存储库进行了一些更改,如何将这些更改拉到另一个本地存储库而不将其推送到远程?
I have two clones of same remote repository. I have made some changes to one local repository, how can I pull these changes to the other local repository without pushing it to the remote?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以像对待另一个系统上的远程存储库一样对待第二个克隆。您可以执行所有相同的操作,例如,
您可以在主克隆中拥有所有第二个克隆的提交,并标有
repo2/
(就像您的远程分支可能标有origin /
或远程/
)。如果您想将远程分支的更改合并到当前的本地分支中,您可以,例如:
You can treat the second clone the same way you treat a remote respository on another system. You can perform all of the same operations, e.g.
You'd then have all your second clone's commits in your main clone, labeled with
repo2/
(just like your remote branches are probably labeled withorigin/
orremote/
).If you then wanted to merge a remote branch's changes into your current local branch, you could then, e.g.:
添加到 DJ 响应。添加本地存储库后,您可以将其视为主存储库,因此所有其他 git 命令都可以正常工作。
例如,如果您在目录 A 中进行了一些更改并将其保存在提交中。要检索目录 B(同一台计算机)中的这些更改,您只需在该目录中打开一个终端,然后 git pull
这将复制目录 A 中的任何更改。我使用这个系统,以便我可以拥有一个“开发”环境(目录 A)和“生产”环境(dir B)。我只 git pull in dir B
To add to djs response. After you add the local repo you can treat it as master, so all the other git commands work as normal.
For example if you have made some changes in directory A and save it in commits. To retrieve those changes in directory B (same computer) you simply open a terminal in that directory and you git pull
This will copy any changes in directory A. I use this system so that I can have a "development" environment (dir A) and a "production" environment (dir B). I only git pull in dir B
对于一次性拉取
将从repo1/branch拉取到repo2/HEAD
For one-time pulling
That will pull from repo1/branch to repo2/HEAD