{"id":13583109,"url":"https://github.com/b1f6c1c4/hub-sync","last_synced_at":"2025-03-24T14:32:50.754Z","repository":{"id":31170996,"uuid":"127079796","full_name":"b1f6c1c4/hub-sync","owner":"b1f6c1c4","description":"Sync your github forks without git.","archived":false,"fork":false,"pushed_at":"2024-11-17T21:11:05.000Z","size":70,"stargazers_count":24,"open_issues_count":3,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-18T13:06:12.795Z","etag":null,"topics":["api","git","github","hub-sync","sync","tools"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@b1f6c1c4/hub-sync","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b1f6c1c4.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-28T03:41:16.000Z","updated_at":"2024-11-17T21:11:03.000Z","dependencies_parsed_at":"2023-11-11T19:27:52.776Z","dependency_job_id":"c2f19464-cb15-4c15-8cf4-577cc3347074","html_url":"https://github.com/b1f6c1c4/hub-sync","commit_stats":{"total_commits":38,"total_committers":2,"mean_commits":19.0,"dds":0.2894736842105263,"last_synced_commit":"6820ce4d1b76fa8836b12aa6fdaf0f6bd1edc628"},"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2Fhub-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2Fhub-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2Fhub-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b1f6c1c4%2Fhub-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b1f6c1c4","download_url":"https://codeload.github.com/b1f6c1c4/hub-sync/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245289799,"owners_count":20591134,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","git","github","hub-sync","sync","tools"],"created_at":"2024-08-01T15:03:15.620Z","updated_at":"2025-03-24T14:32:49.722Z","avatar_url":"https://github.com/b1f6c1c4.png","language":"JavaScript","readme":"# @b1f6c1c4/hub-sync\n\n[![npm](https://img.shields.io/npm/v/@b1f6c1c4/hub-sync.svg?style=flat-square)](https://www.npmjs.com/package/@b1f6c1c4/hub-sync)\n[![npm](https://img.shields.io/npm/dt/@b1f6c1c4/hub-sync.svg?style=flat-square)](https://www.npmjs.com/package/@b1f6c1c4/hub-sync)\n[![GitHub last commit](https://img.shields.io/github/last-commit/b1f6c1c4/hub-sync.svg?style=flat-square)](https://github.com/b1f6c1c4/hub-sync)\n[![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/b1f6c1c4/hub-sync.svg?style=flat-square)](https://github.com/b1f6c1c4/hub-sync)\n[![license](https://img.shields.io/github/license/b1f6c1c4/hub-sync.svg?style=flat-square)](https://github.com/b1f6c1c4/hub-sync/blob/master/LICENSE.md)\n\n\u003e Sync your github forks without git in O(1) time, space, and network BW.\n\n## Basic usage\n\n1. Install the package with *npm* ([nodejs package manager](https://nodejs.org/)).\n\n    ```bash\n    npm i -g @b1f6c1c4/hub-sync\n    ```\n\n1. Update your fork *instantly*.\nFor the first time you run this, you will be asked to generate a [GitHub Personal Access Token](https://github.com/settings/tokens).\nFollow the instructions carefully and **keep your token CONFIDENTIAL.**\n\n    ```bash\n    hub-sync \u003cname-of-your-fork-repository\u003e\n    ```\n\n## Advanced usage\n\n1. Update a certain branch:\n\n    ```bash\n    hub-sync \u003crepo\u003e/\u003cbranch\u003e\n    ```\n\n1. Update from another user's fork:\n\n    ```bash\n    hub-sync \u003cyour-repo\u003e \u003canother-user\u003e\n    ```\n\n1. Update from another user's fork, but with a different name:\n\n    ```bash\n    hub-sync \u003cyour-repo\u003e \u003canother-user\u003e/\u003crepo\u003e\n    ```\n\n1. Update from another user's fork, but with a different name and a different branch:\n\n    ```bash\n    hub-sync \u003cyour-repo\u003e/\u003cbranch\u003e \u003canother-user\u003e/\u003crepo\u003e/\u003cbranch\u003e\n    ```\n\n1. Point a branch of your repo to a specific SHA-1: (rarely used)\n\n    ```bash\n    hub-sync \u003cyour-repo\u003e/\u003cbranch\u003e \u003csha-1\u003e\n    ```\n\n1. Create a new branch:\n\n    ```bash\n    hub-sync -c \u003cdestination\u003e \u003csource\u003e\n    ```\n\n1. Update even if not fast-forward: **(EXTREMELY DANGEROUS)**\n\n    ```bash\n    hub-sync -f \u003cdestination\u003e \u003csource\u003e\n    ```\n\n1. Delete a branch: **(EXTREMELY EXTREMELY DANGEROUS)**\n\n    ```bash\n    hub-sync --delete \u003cdestination\u003e\n    ```\n\n1. See `hub-sync --help` for the complete usage documentation.\n\nNotice: There is **NO SAFETY NET** at all for `-f|--force` and `-d|--delete`.\n**YOU MAY LOSE ALL YOUR WORK ON THAT BRANCH IMMEDIATELY** if not used properly.\nNeither Github nor the author of `hub-sync` will be responsible for your loss.\nUSE AT YOUR OWN RISK. REFER TO THE LICENSE FOR LEGAL ISSUE.\n\n## Technical details\n\nTo keep your github fork up-to-date, the [old-fashioned way](https://help.github.com/articles/syncing-a-fork/) is:\n```sh\ngit clone https://github.com/\u003cyou\u003e/\u003crepo\u003e\ncd \u003crepo\u003e\ngit remote add upstream https://github.com/\u003cother\u003e/\u003crepo\u003e\ngit fetch upstream\ngit push origin upstream/master\u003cmaster\u003e\ncd ..\nrm -rf \u003crepo\u003e.git\n```\nHowever, this is totally pointless since you actually download all the data from github.com and upload all the way back. (I know git may be smart enough to upload only what github.com already has, but you have to download everything first.)\nThis approach takes **as bad as O(n) time, O(n) space, O(n) network bandwidth**.\n\nSo the solution is to call Github API directly:\n```sh\n# Assuming you are using HTTPie:\nhttp GET https://api.github.com/repos/\u003cother\u003e/\u003crepo\u003e/git/refs/heads/master\n# Find object.sha, and\nhttp PATCH https://api.github.com/repos/\u003cyou\u003e/\u003crepo\u003e/git/refs/heads/master \"Authorization\u003ctoken\u003e ...\" sha=...\n# If branch non-exist, use the following instead\nhttp POST https://api.github.com/repos/\u003cyou\u003e/\u003crepo\u003e/git/refs \"Authorization\u003ctoken\u003e ...\" sha=...\n```\n\nNow `hub-sync` does this for you, **as smooth as O(1)**:\n```sh\n# This can be ran everywhere; it works without git.\nhub-sync [-f|-c|-d] \u003cyou\u003e/\u003crepo\u003e/\u003cbranch\u003e \u003cother\u003e/\u003crepo\u003e/\u003cbranch\u003e\n```\n\n### Wanna take more control over the process, but not to clone everything?\n\nYou will need [`git-get`](https://github.com/b1f6c1c4/git-get) and [`git-fancy-push`](https://github.com/b1f6c1c4/git-fancy-push).\nThe latter one resolved the long-standing \"shallow update not allowed\" problem.\n```bash\ngit get -g \u003cyou\u003e/\u003crepo\u003e\ngit remote add upstream ...\ngit fancy-push upstream origin/master:master\n```\n\n## License\n\nMIT\n","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1f6c1c4%2Fhub-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb1f6c1c4%2Fhub-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb1f6c1c4%2Fhub-sync/lists"}