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.
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.
GitHub has now introduced a feature to sync a fork with the click of a button. 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.
Sync from the UI Clicking on that you have the possibility to compare the changes made in the source repo with the ones made in your forked repo, and also to automatically fetch and merge them into your repo.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With