Git pulling changes between two local repositories

GitGit Pull

Git Problem Overview


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?

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

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

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

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionSirishView Question on Stackoverflow
Solution 1 - GitdjsView Answer on Stackoverflow
Solution 2 - GitPedro Moisés Camacho UreñaView Answer on Stackoverflow