git - How to update the code in someone else's repository to the latest version?
三叔
三叔 2017-06-20 10:06:00
0
5
1241

I forked someone else's project on Github, then modified it and submitted a PR according to the normal process, and the other party merged it.

Now I need to contribute code to this project, but I found that someone else has updated the new code in the other party's project warehouse. How can I synchronize the code of the forked project in my own warehouse to the same latest version as the other party's warehouse? code and then I contribute?

三叔
三叔

reply all(5)
世界只因有你

First add other people’s repositories to your upstream remote, usually named upstream. Just do it once.

git remote add upstream  原作者仓库地址

At this time, use git remote -v to see that one origin belongs to you and the other upstream belongs to the original author.

Secondly update the code

Use git fetch upstream to pull the original author’s repository for updates.

Use git checkout master to switch to your own master

Use git merge upstream/master, merge or rebase to your master

为情所困

If the forked code in your warehouse has not been modified since the last time it was merged, then I recommend directly deleting the project in your warehouse and then forking it again.

I personally don’t like the merge method mentioned above -- the history record of the merge method is not very nice.

If you don’t want to delete and re-fork, you can directly:

git checkout master
git remote add upstream 别人的代码库地址
git fetch upstream/master
git reset --hard upstream/master
刘奇

First add the address of the library you forked

git remote add FORK-sync https://github.com/xxx/yyy.git
git remote -v

You can see similar ones

FORK-sync    https://github.com/xxx/yyy.git (fetch)
FORK-sync    https://github.com/xxx/yyy.git (push)
origin    git@github.xxx/born-1.git (fetch)
origin    git@github.xxx/born-1.git (push)

Then accept the contents of the forked library

git fetch FORK-sync

Merge

git merge FORK-sync/master

Just push it to your remote warehouse

git push
Peter_Zhu
cd YOUR-FORKED-REPO
git fetch upstream
git checkout master
git merge upstream/master
仅有的幸福

These graphic tutorials have been available for a long time. http://blog.csdn.net/qq133247...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template