[{"data":1,"prerenderedAt":377},["ShallowReactive",2],{"/2025/04/04/git-tongbu":3,"toc-/2025/04/04/git-tongbu":225,"surround-/2025/04/04/git-tongbu":366},{"id":4,"title":5,"body":6,"categories":202,"date":204,"description":205,"draft":206,"extension":207,"image":208,"meta":209,"navigation":210,"path":211,"readingTime":212,"recommend":190,"references":217,"seo":218,"stem":219,"tags":220,"type":217,"updated":223,"__hash__":224},"content/posts/2025/04/04/Git-tongbu.md","Git 同步上游仓库的更新",{"type":7,"value":8,"toc":189},"minimark",[9,13,17,20,24,32,42,45,48,54,57,60,66,69,75,78,84,87,90,93,99,102,108,111,114,117,123,126,132,161,164,170,180,183],[10,11,5],"h2",{"id":12},"git-同步上游仓库的更新",[14,15,16],"p",{},"　　使用一个 Github Template 创建了我自己的仓库，需要同步一下补丁更新，总不能自己手抄一遍吧，搜了一下解决方案。",[14,18,19],{},"　　记录一下。",[21,22,23],"h3",{"id":23},"添加上游仓库",[14,25,26,27,31],{},"　　给上游仓库取个名字，如果将命名为 ",[28,29,30],"code",{"code":30},"upstream","​ ，可以在本地仓库中运行以下命令：",[33,34,40],"pre",{"className":35,"code":37,"language":38,"meta":39},[36],"language-sh","git remote add upstream https://github.com/$\u003Cupstream-repo>.git\n","sh","",[28,41,37],{"__ignoreMap":39},[21,43,44],{"id":44},"获取上游仓库的更改",[14,46,47],{},"　　运行以下命令以获取上游仓库中的所有分支和提交：",[33,49,52],{"className":50,"code":51,"language":38,"meta":39},[36],"git fetch upstream\n",[28,53,51],{"__ignoreMap":39},[21,55,56],{"id":56},"合并上游更改",[14,58,59],{},"　　现在，将上游 main 分支的更改合并到您的本地 main 分支：",[33,61,64],{"className":62,"code":63,"language":38,"meta":39},[36],"git merge upstream/main --allow-unrelated-histories\n",[28,65,63],{"__ignoreMap":39},[14,67,68],{},"　　如果只需要合并特定的 commit ：",[33,70,73],{"className":71,"code":72,"language":38,"meta":39},[36],"git cherry-pick \u003Ccommit-hash>\n",[28,74,72],{"__ignoreMap":39},[14,76,77],{},"　　也可以使用",[33,79,82],{"className":80,"code":81,"language":38,"meta":39},[36],"gcp \u003Ccommit-hash>\n",[28,83,81],{"__ignoreMap":39},[14,85,86],{},"　　commit-hash 可以直接从 github 网页上复制。",[14,88,89],{},"　　这时 commit 的作者是源仓库的作者， Vercel 提示我 Build 失败，需要升级到 Pro，可以再修改一个文件，自己添加一条 commit 。",[14,91,92],{},"　　当然这很不优雅，可以使用下面的命令获取更改到文件，但是不会提交 commit ，",[33,94,97],{"className":95,"code":96,"language":38,"meta":39},[36],"git cherry-pick \u003Ccommit-hash> --no-commit\n",[28,98,96],{"__ignoreMap":39},[14,100,101],{},"　　然后手动提交一下",[33,103,106],{"className":104,"code":105,"language":38,"meta":39},[36],"git commit -m \"commit information\"\n",[28,107,105],{"__ignoreMap":39},[21,109,110],{"id":110},"解决冲突",[14,112,113],{},"　　如何自己已经修改过源代码，在合并过程中可能发生冲突，需要手动解决。\nGit 也会进行提示，手动编辑冲突文件并保存，然后再提交更改。",[21,115,116],{"id":116},"批量提交",[33,118,121],{"className":119,"code":120,"language":38,"meta":39},[36],"git cherry-pick \u003C起始提交>^..\u003C结束提交>\n",[28,122,120],{"__ignoreMap":39},[14,124,125],{},"　　如果有冲突会按照顺序处理，然后执行， continue 直到结束",[33,127,130],{"className":128,"code":129,"language":38,"meta":39},[36],"git cherry-pick --continue\n",[28,131,129],{"__ignoreMap":39},[133,134,135,143,149,155],"ul",{},[136,137,138,139,142],"li",{},"​",[28,140,141],{"code":141},"\u003C起始提交>","​：范围的开始点（不包含此提交，除非用 \u003C起始提交>~ 或 \u003C起始提交>^）。",[136,144,138,145,148],{},[28,146,147],{"code":147},"\u003C结束提交>","​：范围的结束点（包含此提交）。",[136,150,138,151,154],{},[28,152,153],{"code":153},"^","​ 是 Git 的语法，用于指定“之前的提交”。",[136,156,138,157,160],{},[28,158,159],{"code":159},"..","​ 表示范围。",[21,162,163],{"id":163},"推送",[33,165,168],{"className":166,"code":167,"language":38,"meta":39},[36],"git push origin main\n",[28,169,167],{"__ignoreMap":39},[14,171,172,173,175,176,179],{},"　　当然默认来说，并不会推送到新加入的 ",[28,174,30],{"code":30},"​ ，直接 ",[28,177,178],{"code":178},"git push","​ 即可",[14,181,182],{},"　　如果不再需要同步，可以删除上游的仓库",[33,184,187],{"className":185,"code":186,"language":38,"meta":39},[36],"git remote remove upstream\n",[28,188,186],{"__ignoreMap":39},{"title":39,"searchDepth":190,"depth":190,"links":191},4,[192],{"id":12,"depth":193,"text":5,"children":194},2,[195,197,198,199,200,201],{"id":23,"depth":196,"text":23},3,{"id":44,"depth":196,"text":44},{"id":56,"depth":196,"text":56},{"id":110,"depth":196,"text":110},{"id":116,"depth":196,"text":116},{"id":163,"depth":196,"text":163},[203],"技术分享","2025-04-04 20:13:15","如何同步上游仓库的更新到你的本地仓库。",false,"md","https://i1.wp.com/dev.ruom.top/i/2025/04/07/995956.webp",{},true,"/2025/04/04/git-tongbu",{"text":213,"minutes":214,"time":215,"words":216},"3 min read",2.455,147300,491,null,{"title":5,"description":205},"posts/2025/04/04/Git-tongbu",[221,222],"教程","Git","2025-04-04 20:16:59","9zfqUQ9s4sHtnVMfKrqJe7CU0ht3m4rHi0XpmcflXLM",{"id":4,"title":5,"body":226,"categories":361,"date":204,"description":205,"draft":206,"extension":207,"image":208,"meta":362,"navigation":210,"path":211,"readingTime":363,"recommend":190,"references":217,"seo":364,"stem":219,"tags":365,"type":217,"updated":223,"__hash__":224},{"type":7,"value":227,"toc":351},[228,230,232,234,236,240,245,247,249,254,256,258,263,265,270,272,277,279,281,283,288,290,295,297,299,301,306,308,313,331,333,338,344,346],[10,229,5],{"id":12},[14,231,16],{},[14,233,19],{},[21,235,23],{"id":23},[14,237,26,238,31],{},[28,239,30],{"code":30},[33,241,243],{"className":242,"code":37,"language":38,"meta":39},[36],[28,244,37],{"__ignoreMap":39},[21,246,44],{"id":44},[14,248,47],{},[33,250,252],{"className":251,"code":51,"language":38,"meta":39},[36],[28,253,51],{"__ignoreMap":39},[21,255,56],{"id":56},[14,257,59],{},[33,259,261],{"className":260,"code":63,"language":38,"meta":39},[36],[28,262,63],{"__ignoreMap":39},[14,264,68],{},[33,266,268],{"className":267,"code":72,"language":38,"meta":39},[36],[28,269,72],{"__ignoreMap":39},[14,271,77],{},[33,273,275],{"className":274,"code":81,"language":38,"meta":39},[36],[28,276,81],{"__ignoreMap":39},[14,278,86],{},[14,280,89],{},[14,282,92],{},[33,284,286],{"className":285,"code":96,"language":38,"meta":39},[36],[28,287,96],{"__ignoreMap":39},[14,289,101],{},[33,291,293],{"className":292,"code":105,"language":38,"meta":39},[36],[28,294,105],{"__ignoreMap":39},[21,296,110],{"id":110},[14,298,113],{},[21,300,116],{"id":116},[33,302,304],{"className":303,"code":120,"language":38,"meta":39},[36],[28,305,120],{"__ignoreMap":39},[14,307,125],{},[33,309,311],{"className":310,"code":129,"language":38,"meta":39},[36],[28,312,129],{"__ignoreMap":39},[133,314,315,319,323,327],{},[136,316,138,317,142],{},[28,318,141],{"code":141},[136,320,138,321,148],{},[28,322,147],{"code":147},[136,324,138,325,154],{},[28,326,153],{"code":153},[136,328,138,329,160],{},[28,330,159],{"code":159},[21,332,163],{"id":163},[33,334,336],{"className":335,"code":167,"language":38,"meta":39},[36],[28,337,167],{"__ignoreMap":39},[14,339,172,340,175,342,179],{},[28,341,30],{"code":30},[28,343,178],{"code":178},[14,345,182],{},[33,347,349],{"className":348,"code":186,"language":38,"meta":39},[36],[28,350,186],{"__ignoreMap":39},{"title":39,"searchDepth":190,"depth":190,"links":352},[353],{"id":12,"depth":193,"text":5,"children":354},[355,356,357,358,359,360],{"id":23,"depth":196,"text":23},{"id":44,"depth":196,"text":44},{"id":56,"depth":196,"text":56},{"id":110,"depth":196,"text":110},{"id":116,"depth":196,"text":116},{"id":163,"depth":196,"text":163},[203],{},{"text":213,"minutes":214,"time":215,"words":216},{"title":5,"description":205},[221,222],[367,372],{"title":368,"path":369,"stem":370,"date":371,"type":217,"children":-1},"Markdown 换行语法","/2025/06/28-1/markdown-huanhang","posts/2025/06/28-1/markdown-huanhang","2025-06-28 22:45:50",{"title":373,"path":374,"stem":375,"date":376,"type":217,"children":-1},"Umami博客访问统计Vercel+Cloudflare Wokers部署","/2025/04/06/umami-deploy-cloudflare","posts/2025/04/06/Umami-deploy-cloudflare","2025-04-06 23:25:55",1757075500991]