Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to synchronize fork with original GitHub project?

Tags:

git

github

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?

like image 725
Andrey Bushman Avatar asked Jan 09 '17 07:01

Andrey Bushman


People also ask

How do I sync my fork repo with original repo?

To sync your forked repo with the parent or central repo on GitHub you: Create a pull request on GitHub.com to update your fork of the repository from the original repository, and. Run the git pull command in the terminal to update your local clone.

How do I fork an existing GitHub repository?

You can fork any repo by clicking the fork button in the upper right hand corner of a repo page. Click on the Fork button to fork any repo on github.com.


1 Answers

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
like image 125
Sajib Khan Avatar answered Sep 22 '22 18:09

Sajib Khan