简体   繁体   中英

GitHub - How to Real-Time Sync between 2 GitHub Repos?

Let's say, I've 2 Github Repos :

  1. Rough Codes
  2. Final Codes [ created via Import Old Repo feature of GitHub]

Now. every day I do some tutorials on PHP & whatever I learn, I push it to the Rough Codes Repo. And also I'm building a Project which is pushed to the Final Codes . These Repos are almost the same. What I do now is, Push to the 2 Repo Individually, the same thing twice in the different repo. Which is kinda boring. Is there any way to real-time sync between 2 repos? Like, If I upload/push to the Rough codes it will be auto added to the Final Codes ? I'm using Sourcetree to manage GitHub Repos on Windows OS.

Thanks in Advance.

I can suggest 2 options.

  1. Use 2 branches instead of 2 repos.
  2. Use a fork as your drafts and use PRs to sync to the "main" repo.

Option 1 (2 Branches):

If you don't mind having both codes in the same repo, this is the best option.

You have master branch for "polished" code and a draft branch for "Rough Codes".

You regularly push to draft branch and when you want to "publish" create a pull request (easy) from draft to master and merge changes.

Option 2 (Fork & Pull Request):

In case you don't like to have your "Rough codes" together in the same repo, this is next best choice.

You create a Fork from 2nd github account and use it as a store for "Rough codes". When you are ready to publish polished code, you create to Pull Request to the original repo.

You can get some overall idea about this model from https://reflectoring.io/github-fork-and-pull/

It looks cumbersome initially, but believe me, once you get used to it, it is very easy and clean.

There are few other options, but they are not as clean as the above two.

Hope this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM