3

I have forked a repo on my github. And I also cloned my fork on my desktop like this

git clone myfork.git

and did some commits. How do I keep my fork in sync with the the original repo with my latest commits?

Eric
  • 18,512
  • 4
  • 29
  • 34
Anthony Jo
  • 33
  • 2

2 Answers2

3

Since you already cloned the repository. Now, add your original repository, for convention lets name it original repository. Same as above, Copy-URL of your authors original repository

git remote add original COPY-URL

If you successfully added the remote repository. Now lets fetch that, we are actually pullinig the original here:

git fetch original

Since we fetched the original. Lets merge them

git merge

git merge original/master

How do I update a GitHub forked repository?

You can refer here for more details:

Community
  • 1
  • 1
3

After you commit, you should git fetch upstream, which will get the changes from the parent repository. After this, you should git checkout master, which will move you back to your fork's master branch. The parent repository's changes are held in the upstream/master branch, so you can git merge upstream/master to merge the parent repository's changes into your current fork. This will update your repository, and repeat whenever you want to pull the latest changes from the parent repository.

As stated in the comments, you can use https://help.github.com/articles/syncing-a-fork/ for more help.

Andrew Fan
  • 1,313
  • 5
  • 17
  • 29