Git Fork別人的代碼后如同步別人的代碼


在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

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM