From charlesreid1

Revision as of 22:40, 17 November 2017 by Admin (talk | contribs) (Created page with "If you have forked a remote repository using git, and it has fallen behind several commits, you may need to sync your fork. Here's how to do that. We'll use the hypothetica...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

If you have forked a remote repository using git, and it has fallen behind several commits, you may need to sync your fork.

Here's how to do that.

We'll use the hypothetical Github repos https://github.com/ours/repo for the fork and https://github.com/theirs/repo for the original (forked) repo.

# Start by forking the repo on Github...

# Check out the fork 
git clone https://github.com/ours/repo

# Add the original (forked) repo as the "upstream"
cd repo/
git remote add upstream https://github.com/theirs/repo

# Do some work...

# Oh no, we missed a bunch of changes to the upstream repo!
# Fetch upstream changes
git fetch upstream

# Checkout the master branch of the fork 
# (this assumes the master branch of the original, forked repo is what we want to update from)
git checkout master

# Merge the changes from upstream/master into your local master branch.
git merge upstream/master