📌 26 de Maio, 2017

Git: Syncing a Fork

Informática · Linux · Programação

📌 26 de Maio, 2017

Git: Syncing a Fork

Informática · Linux · Programação

You decided to fork a project on Github, committed some changes and then… the original project was updated. Now you want to merge the changes made to the original project into your fork, and you don’t know how to do it. Today I’m explaining how to update your forks the easy way.

  1. Clone your fork to your working machine:
    git clone git@github.com:YOUR-USERNAME/YOUR-FORKED-REPO.git
  2. Add the original project’s repository to your fork as a remote:
    cd into/cloned/fork-repo
    git remote add upstream git://github.com/ORIGINAL-DEV-USERNAME/REPO-YOU-FORKED-FROM.git
    git fetch upstream
  3. Pull everything:
    git checkout master
    git pull upstream master
  4. Merge the original project (upstream) into your fork (master) and push it:
    git merge upstream/master
    git push

Congrats, your fork is now up to date! Easy isn’t it?