Git 在两个本地存储库之间拉取更改
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/5775580/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Git pulling changes between two local repositories
提问by Poorna
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?
我有两个相同远程存储库的克隆。我对一个本地存储库进行了一些更改,如何将这些更改拉到另一个本地存储库而不将其推送到远程?
回答by djs
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.
您可以像对待另一个系统上的远程存储库一样对待第二个克隆。您可以执行所有相同的操作,例如
~/repo1 $ git remote add repo2 ~/repo2
~/repo1 $ git fetch repo2
~/repo1 $ git merge repo2/foo
回答by Pedro Moisés Camacho Ure?a
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.
添加到 djs 响应。添加本地 repo 后,您可以将其视为 master,因此所有其他 git 命令都可以正常工作。
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
例如,如果您在目录 A 中进行了一些更改并将其保存在提交中。要检索目录 B(同一台计算机)中的这些更改,您只需在该目录中打开一个终端,然后 git pull
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
这将复制目录 A 中的任何更改。我使用这个系统,以便我可以拥有“开发”环境(目录 A)和“生产”环境(目录 B)。我只在目录 B 中 git pull