In fork projects on GitHub, we often encounter updates to the main project. How can we merge the updates to our fork version? Today, someone suddenly asked me this question. I will write it here.
The following uses Ruby-China For example, if I am a user @ tualatrix,
And I have a ruby-China fork version in Here At this time, my local version is Tualatrix/ruby-China
This
# Let me get the tualatrix fork version locally ~ /Work $ git clone git: // github.com/tualatrix/ruby-china.git ~ /Work $ CD ruby-China ~ /Work/ruby-China
$ git remoteorigin # Add huacnlee (that is, the remote address of the main project )~ /Work/ruby-China
$ git remote add huacnlee git: // github.com/huacnlee/ruby-china.git# use the FETCH Command to obtain all the branches of huacnlee ~ /Work/ruby-China
$ git fetch huacnleeremote: counting objects: 499, done. remote: compressing objects: 100% (143/143), done. remote: Total 315 (delta 211), reused 253 (delta 172) Processing ing objects: 100% (315/315), 190.17 kib | 92 kib/s, done. resolving deltas: 100% (211/211), completed with 72 local objects. from git: // github.com/huacnlee/ruby-china * [new branch] Master-> huacnlee/master # Set H The changes to the master branch of uacnlee are merged ~ /Work/ruby-China
$ git merge huacnlee/Master
git remote update updates all remote repositories to ensure consistency. For example, there are two remote repositories: Origin and Korg. After git remote update, the two are consistent and all branches are consistent.