Getting Upstream changes on a repo

A common problem I’ve found especially with the work in AI and github is the need to take code, fork it to make it bend to your current use-case. But with that, you inevitably need to pull the upstream changes down to your fork. But when you do that, you want to make sure you do that in a way that makes sense, and is controlled.

So I would recommend that you do that in the following manner:

  1. Create a landing branch
  2. Pull the upstream changes down to the branch.
  3. Test and validate that the upstream changes don’t impact your deployment.
  4. Submit a PR.

The following instructions will allow you to pull from an upstream repo to your fork, and then PR the changes into your repo.

Step 1 – Add a git remote for the upstream repo:

    git remote add upstream <Url for your git repo>

Step 2 – Then perform a git fetch to get the changes for the upstream switch:

    git fetch upstream

Step 3 – Perform a git checkout to create a landing branch:

    git checkout -b landing-branch upstream/main

Step 4 – Merge the changes from upstream.

    git merge upstream/main

Step 5 – You would then need to perform a git push to push your branch.

    git push --set-upstream origin landing-branch

Step 6 – You can then create a Pull Request to merge this change to main Creating a Pull Request.

Leave a Reply

Your email address will not be published. Required fields are marked *