惊天一问:fork 了别人的仓库后,原作者又更新了仓库,如何将自己的代码和原仓库保持一致呢?
给 fork 配置一个 remote
主要使用 git remote -v
查看远程状态。
git remote -v
# origin https://github.com/shengjk/flink.git (fetch)
# origin https://github.com/shengjk/flink.git (push)
git remote add upstream https://github.com/apache/flink.git
git remote -v
origin https://github.com/shengjk/flink.git (fetch)
origin https://github.com/shengjk/flink.git (push)
upstream https://github.com/apache/flink.git (fetch)
upstream https://github.com/apache/flink.git (push)
git fetch upstream
git fetch upstream
remote: Enumerating objects: 192, done.
remote: Counting objects: 100% (192/192), done.
remote: Compressing objects: 100% (71/71), done.
remote: Total 232 (delta 61), reused 189 (delta 60), pack-reused 40
Receiving objects: 100% (232/232), 42.32 KiB | 147.00 KiB/s, done.
Resolving deltas: 100% (61/61), completed with 24 local objects.
From https://github.com/apache/flink
0ab1549f52..3cbaabc527 master -> upstream/master
de3772bfd2..1b9c464ab3 release-1.6 -> upstream/release-1.6
c193cf04a4..8012ab17bc release-1.7 -> upstream/release-1.7
git checkout master
git checkout master
# Switched to branch 'master'
git merge upstream/master
git merge upstream/master
git push origin master
就好了。