Auto Sync Github Forked Repos
As a Github heavy user, when I saw an interested repos, I would fork them to my “secret” organization to read/use in future. However, when checked them later, most of the time (99%), the repos have already out of synced. There are three options I normally choose:
- delete the forked repo and re-fork;
- manually merge to the latest commit;
- use the PR and switch the source and destination (ref).
Although those three options works like a “charm” in a small amount of repos, it’s more like chores when maintaining hundreds forked repos.
TL;DR
Then I came up the idea to use Travis-CI to sync those repos automatically. The mechanism is simple and straightforward, which runs a script periodically to update forked repos with source repos. The script could be bash, javascript, python, or any language which could call git command in the Linux OS.
My Approach
Based on the above idea, I wrote a js script to do the job. But this script is only a solution my problems:
- Only works on forked repos in a Github Org.
- Forked repos should never be modified.
- User Github personal token to access.
- Not support private repos.
If your needs also match the aboves, then simple fork my script, and modify the org
in .config.yml
.