0

I have a fork from a code uploaded on github. After cloning the fork to my computer, I've adjusted some parts of the code. However, The original code itself has been modified by the writers.

What I want to do is, I want to store my adjustments somewhere, update the fork to match the original code, then add my adjustments to the updated fork without the need of deleting/rewriting anything.

Is that possible? what git commands should I use exactly?!

  • 1
    You can find the answer to your question here: https://stackoverflow.com/questions/7244321/how-do-i-update-a-github-forked-repository – Matias Fuentes Apr 06 '19 at 10:35
  • @MatiasFuentes The part of how to update my fork, I already know. What I'm concerned about is that If I pulled the new writers changes to my computer from the fork using "git pull upstream master" my changes might go away. That's what I want to avoid. – Mohammed Hadi Apr 06 '19 at 10:50

1 Answers1

0

Following the steps in https://stackoverflow.com/a/7244456/4934814 is the way to go, you won't be overriding your changes but instead doing a rebase, which will recreate the commits you've done in the fork in the latest version of master that is in the upstream:

git remote add upstream https://github.com/whoever/whatever.git
git fetch upstream
git checkout master
git rebase upstream/master

Here is some more info on how rebase works: https://git-scm.com/book/en/v2/Git-Branching-Rebasing

Specially important is this part:

With the rebase command, you can take all the changes that were committed on one branch and replay them on a different branch.

Matias Fuentes
  • 439
  • 3
  • 8