在git上fork別人的代碼后,如果別人代碼有更新,自己fork的代碼是不能自動更新的。需要手動操作。
git remote -v 查看是否有遠程分支的別名。例如:git remote -v 后顯示如下,只有自己fork的路徑。需要手動添加。
origin https://github.com/bill1208/incubator-carbondata (fetch)
origin https://github.com/bill1208/incubator-carbondata (push)
git remote add upstream https://github.com/apache/incubator-carbondata 此地址為別人遠程分支的代碼。
再次運行git remote -v
origin https://github.com/bill1208/incubator-carbondata (fetch)
origin https://github.com/bill1208/incubator-carbondata (push)
upstream https://github.com/apache/incubator-carbondata (fetch)
upstream https://github.com/apache/incubator-carbondata (push)
運行git fetch upstream下載遠程分支的代碼
運行git checkout master 切換到本地master分支
運行git merge upstream/master 合並upstream到master。 注意此時只合並了本地的分支,自己fork的遠程分支代碼沒有變化。需要push
運行git push
