I have forked a repository on github some time ago, made a small change and pushed the change back to my github fork. The original repository has changed since. I would like to merge the changes from the original repository to my fork.
I am new to both git and github, and I need specific commands how to do it.
Simply add original repo as a remote and merge your fork with it; then push merged fork to github. There's also a ruby gem for easier github operations.
Fetching changes from a remote repositoryUse git fetch to retrieve new work done by other people. Fetching from a repository grabs all the new remote-tracking branches and tags without merging those changes into your own branches. Otherwise, you can always add a new remote and then fetch.
Merge a Remote Branch to a Local Branch in Git by Tracking and Pulling Changes on the Remote Repository. We will now clone a remote repository containing two branches, master and gh-pages . Then, we will create a local branch another-branch and set it to track any and pull changes made on the remote main branch.
git remote add {name} {Public Clone URL}
git pull {name} master
git push
Example:
git remote add bret git://github.com/bret/watir.git
git pull bret master
git push
git pull origin master
will do the job creating additional merge commit. If you do not have conflicts and do not want to create a rejoin (with additional 'merge' commit) for every commit that you push then rebase
is more preferred. You can do it with the Git Gui+gitk. Just fetch remote with Git Gui
then open history with gitk
and create temporary r_master
branch at remotes/origin/master
fetched. Finally, call git rebase r_master
in the git bash
. This will place your commits on top of the remote modifications. You are ready to push and remove the r_master
.
This comment suggests that there are shortcuts for this flow.
Simply add original repo as a remote and merge your fork with it; then push merged fork to github.
There's also a ruby gem for easier github operations. You can merge upstream with one call...
(from GitHub Help)
https://help.github.com/articles/syncing-a-fork
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