17

I created the fork of some GitHub project. Then I created new branch and did a patch inside of that branch. I sent the pull request to author and he applied my patch and added some commits later. How can I synchronize my fork on GitHub with original project now? Am I to delete my fork on GitHub and create new fork for each my patch each time?

1

1 Answer 1

35

You don't need to refork again. Just add a remote (say, upstream) and fetch upstream to update your cloned repository.

$ git remote add upstream <original-repo-url>
$ git fetch upstream                 # update local with upstream

$ git diff HEAD..upstream/master     # see diffs between local and upstream/master (if there is no diff then both are in sync)

$ git pull upstream master           # pull upstream's master into local branch
$ git push origin HEAD               # push to your forked repo's remote branch

Fetch/get the original repo's new tags:

$ git fetch upstream --tags    # get original repo's tags
$ git push origin --tags       # push to forked repo
4
  • will this sync all new tags from the original project?
    – eastwater
    Commented May 16, 2022 at 18:52
  • @eastwater to sync the tags: git fetch upstream --tags; git push origin --tags
    – Sajib Khan
    Commented May 16, 2022 at 21:42
  • thanks. how about one tag only?
    – eastwater
    Commented May 16, 2022 at 21:51
  • if you want to push only one tag then try this: $ git push origin refs/tags/<tag-name>
    – Sajib Khan
    Commented May 17, 2022 at 13:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.