{"id":17258618,"url":"https://github.com/bobbyrbruce/git-upstream-sync","last_synced_at":"2026-04-27T21:32:11.464Z","repository":{"id":191728757,"uuid":"685265131","full_name":"BobbyRBruce/git-upstream-sync","owner":"BobbyRBruce","description":"A tool to automatically sync a local branch with its upstream counterpart. Useful for syncing local clones of forked repositories.","archived":false,"fork":false,"pushed_at":"2023-09-14T08:24:53.000Z","size":19,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-26T09:21:24.098Z","etag":null,"topics":["branch","fork","forked-repo","git","merge","script","sync","tool","upstream"],"latest_commit_sha":null,"homepage":"","language":"Shell","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/BobbyRBruce.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2023-08-30T21:26:05.000Z","updated_at":"2024-07-11T15:59:20.000Z","dependencies_parsed_at":null,"dependency_job_id":"df6c0d9a-1cb4-4a98-a3e6-1727c8e3ce41","html_url":"https://github.com/BobbyRBruce/git-upstream-sync","commit_stats":null,"previous_names":["bobbyrbruce/git-upstream-merge"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/BobbyRBruce/git-upstream-sync","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobbyRBruce%2Fgit-upstream-sync","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobbyRBruce%2Fgit-upstream-sync/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobbyRBruce%2Fgit-upstream-sync/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobbyRBruce%2Fgit-upstream-sync/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/BobbyRBruce","download_url":"https://codeload.github.com/BobbyRBruce/git-upstream-sync/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/BobbyRBruce%2Fgit-upstream-sync/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32356598,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-27T20:07:02.737Z","status":"ssl_error","status_checked_at":"2026-04-27T20:07:00.910Z","response_time":128,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["branch","fork","forked-repo","git","merge","script","sync","tool","upstream"],"created_at":"2024-10-15T07:21:19.268Z","updated_at":"2026-04-27T21:32:11.446Z","avatar_url":"https://github.com/BobbyRBruce.png","language":"Shell","funding_links":[],"categories":[],"sub_categories":[],"readme":"# git-upstream-sync\n\n`git-upstream-sync` exists when you have three repositories to consider:\n\n* **origin**: The forked repository.\n* **upstream**: The original repository origin is forked from.\n* **local**: A local clone of origin.\n\nIt is assumed the local repository has the upstream and origin repositories configured as remotes.\nIf not, see the section on [Adding \"origin\" and \"upstream\" remotes to your local repository](#adding-origin-and-upstream-remotes-to-your-local-repository).\n\n**Motivation**: If you wish to sync changes from the upstream repository into a branch in your local repository, using just git you have to do the following:\n\n```sh\n# Go to the branch you wish to update.\ngit switch \u003cbranch\u003e\n\n# Fetch the upstream changes.\ngit fetch upstream\n\n# Merge the upstream changes into the local branch.\n# Fast-forward only to \"sync\".\ngit git merge --ff-only upstream/\u003cbranch\u003e\n\n# [Optional] Push the changes to origin repo.\ngit push\n```\n\nDoing this frequently can be tedious.\n\n`git-upstream-sync` automates this process.\nWith it the above can be done by executing `git-upstream-sync -p` within the branch you wish to update in the local repository.\n\n**Note**: By default, the upstream and origin repositories are assumed to be named \"upstream\" and \"origin\" in as remotes in your local repository.\n`git-upstream-sync` has flags `-u` and `-o` to override this.\nFor example, `git-upstream-sync -u another-upstream -o another-origin` will use repositories set as \"another-upstream\" and \"another-origin\" instead.\n\n## Installation\n\nThe \"git-upstream-sync.sh\" script is a script which can be directly.\n`./git-upstream-sync.sh` will execute the script.\n\nIf you wish to use `git-upstream-sync` as a day-to-day tool you may wish to install it somewhere in your system's `PATH`.\nThe install.sh script will do this automatically for you.\nIt will copy \"git-upstream-sync.sh\" to \"/usr/local/bin/\" and renaming it \"git-upstream-sync\" in the process.\n\n```sh\n./install.sh\n```\n\nWhen complete, you should be able to execute `git-upstream-sync` from anywhere in your system.\n\n## Usage\n\nA message on usage will be displayed if you run `git-upstream-sync -h`. The following will be returned:\n\n```txt\ngit-upstream-sync.sh is a tool to to sync a branch on a local clone of a\nforked git repository with its upstream. E.g., An upstream is forked\n    echo  and this fork is cloned locally. A branch X in the local repo can\n    echo be updated to be in-sync with branch X on the upstream via a FF\nmerge.\n\nOptions exist to both pull from origin B prior to this operation \nand push to origin B after.\n\nUsage: ./git-upstream-sync.sh [-b] [-l] [-p] [-o] [-u] [-h]\n-b         : The name of the branch to sync. If this branch doesn't\n             exist it will be created. Defaults to the current\n             branch.\n-p         : Push the branch to the remote origin repository after\n             syncing with the upstream repository.\n-o \u003cremote\u003e: The remote forked repository to sync with Defaults to\n             \"origin\".\n-u \u003cremote\u003e: The remote upstream repository to sync. Defaults to \n             \"upstream\".\n-h         : Display this help message explaining usage.\n\nNote: This tool only supports fast-forward merges. From upstream to\nlocal and from local to origin.\n```\n\n### Working on a feature branch\n\nIf you are working on a feature branch, you may wish to rebase or merge changes from the upstream repository into your feature branch.\n\nLet us assume in this example that your feature branch is named `feature` and it was created from the branch `main` in your local repo.\n`main` is tracking the branch `main` in the origin repository, and that origin repository from the upstream repository.\n\n```sh\n# Go to your feature branch.\ngit switch feature\n\n# Sync the main branch with the upstream repository.\ngit-upstream-sync -b main\n\n# Alternatively, if you want your origin repos main branch to be updated with\n# the upstream repository, you can do:\n# `it-upstream-sync -b main -p``\n\n# Rebase your feature branch on top of the updated main branch.\ngit rebase main\n\n# Alterative, Merge main into feature.\n# `git merge main``\n\n```\n\n## Adding \"origin\" and \"upstream\" remotes to your local repository\n\nIn most cases \"origin\" will be setup as the remote your local repository is cloned from by default.\nIf this is note the case you may do so with:\n\n```sh\ngit remote add origin \u003corigin-repo-url\u003e\n```\n\n`git-upstream-sync` assumes that you have \"upstream\" setup as a remote to your local repository.\nIf not you can do so with:\n\n```sh\ngit remote add upstream \u003cupstream-repo-url\u003e\n```\n\nAs mentioned before, while `git-upstream-sync` assumes the remotes are named \"origin\" and \"upstream\", you can override this with the `-o` and `-u` flags.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbyrbruce%2Fgit-upstream-sync","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbobbyrbruce%2Fgit-upstream-sync","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbobbyrbruce%2Fgit-upstream-sync/lists"}