A forked repository does not auto-update when the original changes. You need to add the original repo as an upstream remote, fetch its commits, and merge (or rebase) them into your local branch.

Sync using Github UI

GitHub provides a "Sync fork" button in the UI as shown below.

Done. No terminal needed.

If there are conflicts, GitHub will tell you it can't auto-sync and will prompt you to open a pull request instead. At that point, fall back to the command-line workflow given below.

Configure the Upstream Remote (One-Time Setup)

Clone your fork first if you haven't already.

$ git clone https://github.com/YOUR-USERNAME/mlops-for-devops.git

$ cd mlops-for-devops

Check what remotes are currently configured:

git remote -v

You'll see only origin pointing to your fork:

origin  https://github.com/YOUR-USERNAME/mlops-for-devops.git (fetch)
origin  https://github.com/YOUR-USERNAME/mlops-for-devops.git (push)

Now add the upstream remote:

git remote add upstream https://github.com/techiescamp/mlops-for-devops.git

Confirm it worked:

git remote -v
origin    https://github.com/YOUR-USERNAME/mlops-for-devops.git (fetch)
origin    https://github.com/YOUR-USERNAME/mlops-for-devops.git (push)
upstream  https://github.com/techiescamp/mlops-for-devops.git (fetch)
upstream  https://github.com/techiescamp/mlops-for-devops.git (push)

You only do this once per clone. After this, the upstream remote persists in your local git config.

Tip: If the upstream URL ever changes (repo renamed, org moved), update it with git remote set-url upstream <new-url>.

Step 2: Fetch and Merge Upstream Changes

This is the core workflow. Three commands, every time you want to sync.

Fetch upstream commits

This downloads all new commits from the upstream repo into your local git database. Nothing changes in your working directory yet.

git fetch upstream

Output looks something like this:

remote: Enumerating objects: 45, done.
remote: Counting objects: 100% (45/45), done.
remote: Compressing objects: 100% (18/18), done.
remote: Total 32 (delta 14), reused 0 (delta 0)
Unpacking objects: 100% (32/32), done.
From https://github.com/techiescamp/mlops-for-devops
 * [new branch]      main       -> upstream/main

Check out your local main branch

git checkout main

Merge upstream/main into your branch

git merge upstream/main

If your fork has no conflicting commits, git does a fast-forward merge. Clean, no merge commit:

Updating a422352..5fdff0f
Fast-forward
 phase-1-local-dev/pipeline.py  | 42 ++++++++
 phase-1-local-dev/README.md    |  9 +++
 2 files changed, 51 insertions(+)

Push the synced state to your fork on GitHub

git push origin main

Your fork on GitHub is now up to date.

Reply

Avatar

or to participate

Keep Reading