How do I update or sync a forked repository on GitHub?

The explanation for update or sync a forked.

Here we will learn How to update or sync a forked repository on GitHub. So we can add the original GitHub repository as a “remote”. In our local clone of your forked repository. And this remote works as a nickname for the URLs of repositories. After that, we can have all the branches from that upstream repository. And can arrange the work to continue working on the upstream version. In terms of commands that might look like:

# 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

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

You can replace the last command  git merge upstream/master if you don’t want to rewrite the history of your master branch. However, for making further pull requests that are as clean as possible, it’s probably better to rebase.

So if you rearrange the branch that belongs to you on. So at that time, you will need to force it to push in order to push it so that it will be your own fork repository on GitHub. And you will do this with the following statement:

git push -f origin master

After you’ve rebased for the first time you only need to use the -f.

 

Also, read How do I redirect to another webpage?

Share this post

Leave a Reply

Your email address will not be published. Required fields are marked *