Articles

How to sync a forked git repository?

In howto on Jul 13, 2016 by theoryl Tagged: , , ,

To synchronize your forked Git repository with the upstream, follow these nice instructions on StackOverflow:

# Add the remote, call it "upstream":

git remote add upstream https://github.com/whoever/whatever.git

# Fetch all the branches of that remote into remote-tracking branches,
# such as upstream/master:

git fetch upstream

# Make sure that you're on your master branch:

git checkout master

# Rewrite your master branch so that any commits of yours that
# aren't already in upstream/master are replayed on top of that
# other branch:

git rebase upstream/master

# If you don't want to rewrite the history of your master branch,
# then you should replace the last command with the following

#git merge upstream/master

# Now push your branch to your own forked repository

git push origin master

# If you've rebased your branch onto upstream/master you may need to
# force the push in order to push it to your own forked repository

#git push -f origin master
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: