Let's Keep Your Fork Repo The Latest

0xkoji - Apr 5 '21 - - Dev Community

Pre-condition

  • you have github account
  • you have git on your local machine
  • you have a fork repo
  • you have cloned the fork repo

In this post, I use https://github.com/memo/eco-nft as the original repo.

My forked repo is https://github.com/koji/eco-nft.git

set original repo

# add remote repo as upstream
$ git remote add upstream https://github.com/original_repo_you_forked

# check info
$ git remote -v
origin  https://github.com/koji/eco-nft.git (fetch)
origin  https://github.com/koji/eco-nft.git (push)
upstream    https://github.com/memo/eco-nft (fetch)
upstream    https://github.com/memo/eco-nft (push)
Enter fullscreen mode Exit fullscreen mode

fetch & merge

$ git fetch upstream

# merge upstream into my forked repo's master branch
$ git merge upstream/master
Enter fullscreen mode Exit fullscreen mode

push (to make a forked repo updated)

$ git push origin master
Enter fullscreen mode Exit fullscreen mode

remove upstream from remote

If you added a wrong url, you would need to remove it with the following command.

$ git remote rm upstream
Enter fullscreen mode Exit fullscreen mode
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .