Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pulling changes from fork parent in Git

Tags:

How do you pull changes from the parent of a fork in Git, specifically in a github configured project?

For example, say I forked http://github.com/originaluser/originalproject into http://github.com/myuser/myproject. I don't plan on myproject on being a permanent fork, as I only want to maintain a "dev" branch to test some experimental features, and then eventually merge it back into the original project.

As such, whenever commits are made to originalproject, I want to be able to pull them down and merge them with myproject. However, I also want to be able to push changes up into myproject, but not yet immediately create a pull request to get them merged into originalproject until my branch is complete and tested. What's the best way to do this?

Edit: By default, when I create a local checkout/fork of my github fork for local development, and then push/pull changes up, these changes only effect my personal fork. I never get changes from the original project. How do I fix that?

Sorry for any incorrect git terminology.

like image 788
Cerin Avatar asked Dec 11 '12 20:12

Cerin


People also ask

How do you pull changes from a forked project?

Go to your fork, click on Fetch upstream , and then click on Fetch and merge to directly sync your fork with its parent repo. You may also click on the Compare button to compare the changes before merging.


2 Answers

Expanding on other answers, these are the steps I took on a fork I had of tsc-watch:

git remote add upstream https://github.com/gilamran/tsc-watch.git git fetch upstream git merge upstream/master git push 

Explained:

  1. adding the remote server as upstream (alias)
  2. fetch all changes from the upstream remote
  3. merge changes from upstream/master branch into my current branch
  4. push all changes to GitHub
like image 165
Frank Orellana Avatar answered Nov 17 '22 13:11

Frank Orellana


You can add the parent repository (upstream) as another remote branch. Something like

git remote add upstream ... 

and then you can just git fetch to see any changes and then rebase/merge... whatever.

like image 30
Jiří Pospíšil Avatar answered Nov 17 '22 12:11

Jiří Pospíšil