Advertisement
rehannali

Copy Repo

Jun 5th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 2.46 KB | None | 0 0
  1. Duplicating a repository
  2. MAC WINDOWS LINUX
  3. To duplicate a repository without forking it, you can run a special clone command, then mirror-push to the new repository.
  4.  
  5. Before you can duplicate a repository and push to your new copy, or mirror, of the repository, you must create the new repository on GitHub. In these examples, exampleuser/new-repository or exampleuser/mirrored are the mirrors.
  6.  
  7. Mirroring a repository
  8. Open Terminal.
  9.  
  10. Create a bare clone of the repository.
  11.  
  12. git clone --bare https://github.com/exampleuser/old-repository.git
  13. Mirror-push to the new repository.
  14.  
  15. cd old-repository.git
  16. git push --mirror https://github.com/exampleuser/new-repository.git
  17. Remove the temporary local repository you created in step 1.
  18.  
  19. cd ..
  20. rm -rf old-repository.git
  21. Mirroring a repository that contains Git Large File Storage objects
  22. Open Terminal.
  23.  
  24. Create a bare clone of the repository. Replace the example username with the name of the person or organization who owns the repository, and replace the example repository name with the name of the repository you'd like to duplicate.
  25.  
  26. git clone --bare https://github.com/exampleuser/old-repository.git
  27. Navigate to the repository you just cloned.
  28.  
  29. cd old-repository.git
  30. Pull in the repository's Git Large File Storage objects.
  31.  
  32. git lfs fetch --all
  33. Mirror-push to the new repository.
  34.  
  35. git push --mirror https://github.com/exampleuser/new-repository.git
  36. Push the repository's Git Large File Storage objects to your mirror.
  37.  
  38. git lfs push --all https://github.com/exampleuser/new-repository.git
  39. Remove the temporary local repository you created in step 1.
  40.  
  41. cd ..
  42. rm -rf old-repository.git
  43. Mirroring a repository in another location
  44. 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.
  45.  
  46. Open Terminal.
  47.  
  48. Create a bare mirrored clone of the repository.
  49.  
  50. git clone --mirror https://github.com/exampleuser/repository-to-mirror.git
  51. Set the push location to your mirror.
  52.  
  53. cd repository-to-mirror.git
  54. git remote set-url --push origin https://github.com/exampleuser/mirrored
  55. 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.
  56.  
  57. git fetch -p origin
  58. git push --mirror
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement