Update my github repo which is forked out from another project

GitGithub

Git Problem Overview


I have forked out a Parent: project to Child: this. Now, I want to update my child with parents current updates. Can I do that, if yes how?

When I update my github repo, then I can do a "git pull" to update my local repo.

Git Solutions


Solution 1 - Git

In your local clone of Child, pull from Parent, adding it as a remote if you like:

cd child
git remote add parent <parent-url>
git pull parent

The url of the parent could be the public github repo, or your local clone of it - the local clone will of course be faster. If you want to pull a branch other than the current HEAD of the parent repo, just add an argument (e.g. git pull parent topic-branch). If this is a one-time thing, you can just skip adding the remote: git pull <parent-url> [branch].

Pulling is a combination of fetching and merging, so once you've done that, you've got a new merge commit you'll presumably want to push back to your public repo at some point.

The key point here, in case it's not clear, is that pulling from the parent (upstream) repository is not different from pulling from your public clone of child, your current repository. Either way, you're fetching from a repository with some common history, and merging that into your current branch. And of course, since you're merging, a work tree is required - so this is something that must be done in your local repo. The repo hosted on github is essentially a way of publishing what you've done locally. All you can really do with it is push/pull, and browse what's there.

Solution 2 - Git

  1. Clone your repo to your local machine, if you haven't already: git clone [email protected]:utkarsh2012/voldemort.git
  2. Add the upstream as a new remote: git remote add upstream git://github.com/voldemort/voldemort.git
  3. With your branch checked out, pull the upstream into your branch, which will create a merge between the two sets of changes: git pull upstream or git pull upstream branch-to-merge. If you're working on an unpushed branch you can also use git fetch and git rebase to rebase your work without needing a merge.

Solution 3 - Git

You want:

git pull git://github.com/voldemort/voldemort.git

Solution 4 - Git

This can also be done simply on GitHub's web interface: issue a Pull Request but swap the base repo and head repo. If the pull can be performed automatically, it will be.

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionzengrView Question on Stackoverflow
Solution 1 - GitCascabelView Answer on Stackoverflow
Solution 2 - GithobbsView Answer on Stackoverflow
Solution 3 - GitLuke FranclView Answer on Stackoverflow
Solution 4 - GitthSoftView Answer on Stackoverflow