0

I have bare cloned a public github repository(say projectA) and created a private github repository (say projectAPrivate), then mirror pushed the cloned projectA to projectAPrivate(as outlined here https://help.github.com/articles/duplicating-a-repository

git clone --bare https://github.com/exampleuser/old-repository.git
# Make a bare clone of the repository

cd old-repository.git
git push --mirror https://github.com/exampleuser/new-repository.git
# Mirror-push to the new repository

cd ..
rm -rf old-repository.git
# Remove our temporary local repository

)

Since then, I have pushed changes to projectAPrivate, now projectA has released new versions. How do I have pull/merge changes from the public projectA repository to my private github project projectAPrivate.

Michael Z
  • 4,534
  • 4
  • 21
  • 27
  • Came across this SO by way of Google. The full answer is at https://stackoverflow.com/questions/10065526/github-how-to-make-a-fork-of-public-repository-private – David Tobiano Jun 24 '17 at 22:28

2 Answers2

0

I think Github's help page has also the answer to your question: https://help.github.com/articles/duplicating-a-repository

If you want to mirror a repository in another location, including getting updates from the original, you can clone a mirror and periodically push the changes.

$ git clone --mirror
$ https://github.com/exampleuser/repository-to-mirror.git
# Make a bare mirrored clone of the repositor

$ cd repository-to-mirror.git git remote set-url --push origin
$ https://github.com/exampleuser/mirrored
# Set the push location to your mirror 

As with a bare clone, a mirrored clone includes all remote branches and tags, but all local references will be overwritten each time you fetch, so it will always be the same as the original repository. Setting the URL for pushes simplifies pushing to your mirror. To update your mirror, fetch updates and push, which could be automated by running a cron job.

git fetch -p origin 
git push --mirror
lemiorhan
  • 1,434
  • 11
  • 18
0

You can run the follow command on the projectAPrivate root directory

git remote add public https://github.com/exampleuser/old-repository.git
git pull public master

Then you will get all the updates from projectA repository, then please merge the changes, resolve conflicts etc, and after that, you can run the follow command to commit it to projectAPrivate

git push origin master
Lawrence Liu
  • 454
  • 3
  • 18