2025/05/19
How to upgrade forked github repository and merge customed code

Here is steps

  1. Check out your own forked repository
git clone git@github.com:aidabo/Ghost.git
  1. Link your local fork to the original repository to fetch updates:
git remote add upstream https://github.com/TryGhost/Ghost.git
  1. Pull all branches, tags, and commits from the original repository:
git fetch upstream --tags
  1. Create a branch based on the upstream tag (e.g., v5.116.2):
git checkout -b new-upstream-version v5.116.2
  1. Rebase Your Custom Code onto the New Version

Rebase to apply your changes on top of the latest upstream code
(here git checkout custom-feature custom-feature is main, can be branch and tags):

   git checkout main
   git rebase new-upstream-version

Resolve conflicts during rebase, then continue:

   git rebase --continue
  1. Resolve Merge/Rebase Conflicts

Git will pause if conflicts occur. Open conflicting files, edit them to resolve discrepancies, then mark them as resolved:

git add resolved-file.js

Complete the merge/rebase after resolving all conflicts and commit.

git commit -m "merged upgraded files"
  1. Push Updated Code to Your Fork
git push origin main --force-with-lease