[{"data":1,"prerenderedAt":1967},["ShallowReactive",2],{"post-2026-05-05-gitadvanced":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"tags":11,"body":14,"_type":1961,"_id":1962,"_source":1963,"_file":1964,"_stem":1965,"_extension":1966},"\u002Fblog\u002F2026-05-05-gitadvanced","blog",false,"","Git 进阶篇","Git 进阶教程：远程仓库操作、SSH公钥配置、PyCharm中Git可视化管理、分支合并冲突解决。","2026-05-05",[12,13],"Git","版本控制",{"type":15,"children":16,"toc":1940},"root",[17,26,39,53,156,160,166,180,189,195,200,208,214,656,722,728,1157,1163,1176,1207,1213,1218,1367,1373,1383,1400,1408,1420,1426,1432,1437,1445,1451,1607,1613,1666,1672,1816,1822,1901,1907,1934],{"type":18,"tag":19,"props":20,"children":22},"element","h2",{"id":21},"_1-git-远程仓库",[23],{"type":24,"value":25},"text","1 Git 远程仓库",{"type":18,"tag":27,"props":28,"children":30},"h3",{"id":29},"_11-常用的托管服务-远程仓库",[31,33],{"type":24,"value":32},"1.1 常用的托管服务 ",{"type":18,"tag":34,"props":35,"children":36},"span",{},[37],{"type":24,"value":38},"远程仓库",{"type":18,"tag":40,"props":41,"children":42},"p",{},[43,45,51],{"type":24,"value":44},"前面我们已经知道了Git中存在两种类型的仓库，即",{"type":18,"tag":46,"props":47,"children":48},"strong",{},[49],{"type":24,"value":50},"本地仓库和远程仓库",{"type":24,"value":52},"。那么我们如何搭建Git远程仓库呢？我们可以借助互联网上提供的一些代码托管服务来实现，其中比较常用的有 GitHub、码云、GitLab 等。",{"type":18,"tag":54,"props":55,"children":56},"table",{},[57,83],{"type":18,"tag":58,"props":59,"children":60},"thead",{},[61],{"type":18,"tag":62,"props":63,"children":64},"tr",{},[65,72,77],{"type":18,"tag":66,"props":67,"children":69},"th",{"align":68},"center",[70],{"type":24,"value":71},"平台",{"type":18,"tag":66,"props":73,"children":74},{"align":68},[75],{"type":24,"value":76},"地址",{"type":18,"tag":66,"props":78,"children":80},{"align":79},"left",[81],{"type":24,"value":82},"特点",{"type":18,"tag":84,"props":85,"children":86},"tbody",{},[87,112,134],{"type":18,"tag":62,"props":88,"children":89},{},[90,96,107],{"type":18,"tag":91,"props":92,"children":93},"td",{"align":68},[94],{"type":24,"value":95},"GitHub",{"type":18,"tag":91,"props":97,"children":98},{"align":68},[99],{"type":18,"tag":100,"props":101,"children":105},"a",{"href":102,"rel":103},"https:\u002F\u002Fgithub.com\u002F",[104],"nofollow",[106],{"type":24,"value":102},{"type":18,"tag":91,"props":108,"children":109},{"align":79},[110],{"type":24,"value":111},"面向开源及私有软件项目的托管平台，只支持Git作为唯一的版本库格式进行托管",{"type":18,"tag":62,"props":113,"children":114},{},[115,120,129],{"type":18,"tag":91,"props":116,"children":117},{"align":68},[118],{"type":24,"value":119},"Gitee",{"type":18,"tag":91,"props":121,"children":122},{"align":68},[123],{"type":18,"tag":100,"props":124,"children":127},{"href":125,"rel":126},"https:\u002F\u002Fgitee.com\u002F",[104],[128],{"type":24,"value":125},{"type":18,"tag":91,"props":130,"children":131},{"align":79},[132],{"type":24,"value":133},"国内代码托管平台，服务器在国内，访问速度比GitHub更快",{"type":18,"tag":62,"props":135,"children":136},{},[137,142,151],{"type":18,"tag":91,"props":138,"children":139},{"align":68},[140],{"type":24,"value":141},"GitLab",{"type":18,"tag":91,"props":143,"children":144},{"align":68},[145],{"type":18,"tag":100,"props":146,"children":149},{"href":147,"rel":148},"https:\u002F\u002Fabout.gitlab.com\u002F",[104],[150],{"type":24,"value":147},{"type":18,"tag":91,"props":152,"children":153},{"align":79},[154],{"type":24,"value":155},"用于仓库管理系统的开源项目，基于Git搭建的Web服务，常用于企业、学校等内部网络搭建Git私服",{"type":18,"tag":157,"props":158,"children":159},"hr",{},[],{"type":18,"tag":27,"props":161,"children":163},{"id":162},"_12-注册码云gitee",[164],{"type":24,"value":165},"1.2 注册码云(Gitee)",{"type":18,"tag":40,"props":167,"children":168},{},[169],{"type":18,"tag":46,"props":170,"children":171},{},[172,174],{"type":24,"value":173},"Gitee官网 注册地址：",{"type":18,"tag":100,"props":175,"children":178},{"href":176,"rel":177},"https:\u002F\u002Fgitee.com\u002Fsignup",[104],[179],{"type":24,"value":176},{"type":18,"tag":40,"props":181,"children":182},{},[183],{"type":18,"tag":184,"props":185,"children":188},"img",{"alt":186,"src":187},"1775736967952","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775736967952.png",[],{"type":18,"tag":27,"props":190,"children":192},{"id":191},"_13-创建远程仓库",[193],{"type":24,"value":194},"1.3 创建远程仓库",{"type":18,"tag":40,"props":196,"children":197},{},[198],{"type":24,"value":199},"根据个人所需创建远程仓库，若存在本地仓库，则不建议勾选创建按钮上方的三个复选框。",{"type":18,"tag":40,"props":201,"children":202},{},[203],{"type":18,"tag":184,"props":204,"children":207},{"alt":205,"src":206},"1775737746677","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775737746677.png",[],{"type":18,"tag":27,"props":209,"children":211},{"id":210},"_14-配置ssh公钥",[212],{"type":24,"value":213},"1.4 配置SSH公钥",{"type":18,"tag":215,"props":216,"children":217},"ol",{},[218,258,466,498,511],{"type":18,"tag":219,"props":220,"children":221},"li",{},[222,224],{"type":24,"value":223},"生成SSH公钥",{"type":18,"tag":225,"props":226,"children":230},"pre",{"className":227,"code":228,"language":229,"meta":7,"style":7},"language-bash shiki shiki-themes github-dark","ssh-keygen -t rsa\n","bash",[231],{"type":18,"tag":232,"props":233,"children":234},"code",{"__ignoreMap":7},[235],{"type":18,"tag":34,"props":236,"children":239},{"class":237,"line":238},"line",1,[240,246,252],{"type":18,"tag":34,"props":241,"children":243},{"style":242},"--shiki-default:#B392F0",[244],{"type":24,"value":245},"ssh-keygen",{"type":18,"tag":34,"props":247,"children":249},{"style":248},"--shiki-default:#79B8FF",[250],{"type":24,"value":251}," -t",{"type":18,"tag":34,"props":253,"children":255},{"style":254},"--shiki-default:#9ECBFF",[256],{"type":24,"value":257}," rsa\n",{"type":18,"tag":219,"props":259,"children":260},{},[261,263,267,272,275,277,294,350,358,428,431,433,439,441],{"type":24,"value":262},"一路回车，使用默认值即可。",{"type":18,"tag":264,"props":265,"children":266},"br",{},[],{"type":18,"tag":184,"props":268,"children":271},{"alt":269,"src":270},"1775804920198","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775804920198.png",[],{"type":18,"tag":264,"props":273,"children":274},{},[],{"type":24,"value":276},"也可以选择对密钥进行详细的配置，执行后会出现提示：",{"type":18,"tag":278,"props":279,"children":280},"ul",{},[281],{"type":18,"tag":219,"props":282,"children":283},{},[284,286,292],{"type":24,"value":285},"首先询问密钥保存路径，直接按回车使用默认路径（",{"type":18,"tag":232,"props":287,"children":289},{"className":288},[],[290],{"type":24,"value":291},"~\u002F.ssh\u002Fid_rsa",{"type":24,"value":293},"）",{"type":18,"tag":225,"props":295,"children":297},{"className":227,"code":296,"language":229,"meta":7,"style":7},"Enter file in which to save the key (\u002Fc\u002FUsers\u002FYOU\u002F.ssh\u002Fid_ALGORITHM): 回车\n",[298],{"type":18,"tag":232,"props":299,"children":300},{"__ignoreMap":7},[301],{"type":18,"tag":34,"props":302,"children":303},{"class":237,"line":238},[304,309,314,319,324,329,334,339,344],{"type":18,"tag":34,"props":305,"children":306},{"style":242},[307],{"type":24,"value":308},"Enter",{"type":18,"tag":34,"props":310,"children":311},{"style":254},[312],{"type":24,"value":313}," file",{"type":18,"tag":34,"props":315,"children":316},{"style":254},[317],{"type":24,"value":318}," in",{"type":18,"tag":34,"props":320,"children":321},{"style":254},[322],{"type":24,"value":323}," which",{"type":18,"tag":34,"props":325,"children":326},{"style":254},[327],{"type":24,"value":328}," to",{"type":18,"tag":34,"props":330,"children":331},{"style":254},[332],{"type":24,"value":333}," save",{"type":18,"tag":34,"props":335,"children":336},{"style":254},[337],{"type":24,"value":338}," the",{"type":18,"tag":34,"props":340,"children":341},{"style":254},[342],{"type":24,"value":343}," key",{"type":18,"tag":34,"props":345,"children":347},{"style":346},"--shiki-default:#E1E4E8",[348],{"type":24,"value":349}," (\u002Fc\u002FUsers\u002FYOU\u002F.ssh\u002Fid_ALGORITHM): 回车\n",{"type":18,"tag":278,"props":351,"children":352},{},[353],{"type":18,"tag":219,"props":354,"children":355},{},[356],{"type":24,"value":357},"然后会提示设置密码（可选），直接按回车跳过即可（无需密码）",{"type":18,"tag":225,"props":359,"children":361},{"className":227,"code":360,"language":229,"meta":7,"style":7},"Enter passphrase (empty for no passphrase): 输入密码\nEnter same passphrase again: 再次输入密码\n",[362],{"type":18,"tag":232,"props":363,"children":364},{"__ignoreMap":7},[365,401],{"type":18,"tag":34,"props":366,"children":367},{"class":237,"line":238},[368,372,377,382,387,392,396],{"type":18,"tag":34,"props":369,"children":370},{"style":242},[371],{"type":24,"value":308},{"type":18,"tag":34,"props":373,"children":374},{"style":254},[375],{"type":24,"value":376}," passphrase",{"type":18,"tag":34,"props":378,"children":379},{"style":346},[380],{"type":24,"value":381}," (empty ",{"type":18,"tag":34,"props":383,"children":384},{"style":254},[385],{"type":24,"value":386},"for",{"type":18,"tag":34,"props":388,"children":389},{"style":254},[390],{"type":24,"value":391}," no",{"type":18,"tag":34,"props":393,"children":394},{"style":254},[395],{"type":24,"value":376},{"type":18,"tag":34,"props":397,"children":398},{"style":346},[399],{"type":24,"value":400},"): 输入密码\n",{"type":18,"tag":34,"props":402,"children":404},{"class":237,"line":403},2,[405,409,414,418,423],{"type":18,"tag":34,"props":406,"children":407},{"style":242},[408],{"type":24,"value":308},{"type":18,"tag":34,"props":410,"children":411},{"style":254},[412],{"type":24,"value":413}," same",{"type":18,"tag":34,"props":415,"children":416},{"style":254},[417],{"type":24,"value":376},{"type":18,"tag":34,"props":419,"children":420},{"style":254},[421],{"type":24,"value":422}," again:",{"type":18,"tag":34,"props":424,"children":425},{"style":254},[426],{"type":24,"value":427}," 再次输入密码\n",{"type":18,"tag":264,"props":429,"children":430},{},[],{"type":24,"value":432},"生成成功后，再次执行 ",{"type":18,"tag":232,"props":434,"children":436},{"className":435},[],[437],{"type":24,"value":438},"ls -al ~\u002F.ssh",{"type":24,"value":440}," 就能看到新生成的密钥文件：",{"type":18,"tag":278,"props":442,"children":443},{},[444,455],{"type":18,"tag":219,"props":445,"children":446},{},[447,453],{"type":18,"tag":232,"props":448,"children":450},{"className":449},[],[451],{"type":24,"value":452},"id_rsa",{"type":24,"value":454},"（私钥，务必保密，不要分享给任何人）",{"type":18,"tag":219,"props":456,"children":457},{},[458,464],{"type":18,"tag":232,"props":459,"children":461},{"className":460},[],[462],{"type":24,"value":463},"id_rsa.pub",{"type":24,"value":465},"（公钥，需要添加到 GitHub 的文件）",{"type":18,"tag":219,"props":467,"children":468},{},[469,471,476,478],{"type":24,"value":470},"查看SSH公钥文件 ",{"type":18,"tag":232,"props":472,"children":474},{"className":473},[],[475],{"type":24,"value":463},{"type":24,"value":477}," 的内容且进行复制：",{"type":18,"tag":225,"props":479,"children":481},{"className":227,"code":480,"language":229,"meta":7,"style":7},"cat ~\u002F.ssh\u002Fid_rsa.pub\n",[482],{"type":18,"tag":232,"props":483,"children":484},{"__ignoreMap":7},[485],{"type":18,"tag":34,"props":486,"children":487},{"class":237,"line":238},[488,493],{"type":18,"tag":34,"props":489,"children":490},{"style":242},[491],{"type":24,"value":492},"cat",{"type":18,"tag":34,"props":494,"children":495},{"style":254},[496],{"type":24,"value":497}," ~\u002F.ssh\u002Fid_rsa.pub\n",{"type":18,"tag":219,"props":499,"children":500},{},[501,503,506],{"type":24,"value":502},"完整的复制SSH公钥后打开Gitee的SSH配置页面，将公钥复制到输入框中并保存，然后输入账户密码验证即可，如下图所示：",{"type":18,"tag":264,"props":504,"children":505},{},[],{"type":18,"tag":184,"props":507,"children":510},{"alt":508,"src":509},"1775805298552","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775805298552.png",[],{"type":18,"tag":219,"props":512,"children":513},{},[514,516,541,544,546,552,554],{"type":24,"value":515},"返回 Git Bash 输入下列指令测试你的电脑能否通过 SSH 协议，成功连接到 Gitee 服务器，并验证你的密钥是否正确：",{"type":18,"tag":225,"props":517,"children":519},{"className":227,"code":518,"language":229,"meta":7,"style":7},"ssh -T git@gitee.com\n",[520],{"type":18,"tag":232,"props":521,"children":522},{"__ignoreMap":7},[523],{"type":18,"tag":34,"props":524,"children":525},{"class":237,"line":238},[526,531,536],{"type":18,"tag":34,"props":527,"children":528},{"style":242},[529],{"type":24,"value":530},"ssh",{"type":18,"tag":34,"props":532,"children":533},{"style":248},[534],{"type":24,"value":535}," -T",{"type":18,"tag":34,"props":537,"children":538},{"style":254},[539],{"type":24,"value":540}," git@gitee.com\n",{"type":18,"tag":264,"props":542,"children":543},{},[],{"type":24,"value":545},"首次连接可能出现下面的提示，此时只需在结尾处输入 ",{"type":18,"tag":232,"props":547,"children":549},{"className":548},[],[550],{"type":24,"value":551},"yes",{"type":24,"value":553},"，如下：",{"type":18,"tag":225,"props":555,"children":557},{"className":227,"code":556,"language":229,"meta":7,"style":7},"Are you sure you want to continue connecting (yes\u002Fno\u002F[fingerprint])? yes\n\n# 若成功，则出现类似下列内容的语句\nHi 用户名! You've successfully authenticated, but GITEE.COM does not provide shell access.\n",[558],{"type":18,"tag":232,"props":559,"children":560},{"__ignoreMap":7},[561,618,627,637],{"type":18,"tag":34,"props":562,"children":563},{"class":237,"line":238},[564,569,574,579,583,588,592,597,602,607,613],{"type":18,"tag":34,"props":565,"children":566},{"style":242},[567],{"type":24,"value":568},"Are",{"type":18,"tag":34,"props":570,"children":571},{"style":254},[572],{"type":24,"value":573}," you",{"type":18,"tag":34,"props":575,"children":576},{"style":254},[577],{"type":24,"value":578}," sure",{"type":18,"tag":34,"props":580,"children":581},{"style":254},[582],{"type":24,"value":573},{"type":18,"tag":34,"props":584,"children":585},{"style":254},[586],{"type":24,"value":587}," want",{"type":18,"tag":34,"props":589,"children":590},{"style":254},[591],{"type":24,"value":328},{"type":18,"tag":34,"props":593,"children":594},{"style":254},[595],{"type":24,"value":596}," continue",{"type":18,"tag":34,"props":598,"children":599},{"style":254},[600],{"type":24,"value":601}," connecting",{"type":18,"tag":34,"props":603,"children":604},{"style":346},[605],{"type":24,"value":606}," (yes\u002Fno\u002F[fingerprint])",{"type":18,"tag":34,"props":608,"children":610},{"style":609},"--shiki-default:#F97583",[611],{"type":24,"value":612},"?",{"type":18,"tag":34,"props":614,"children":615},{"style":346},[616],{"type":24,"value":617}," yes\n",{"type":18,"tag":34,"props":619,"children":620},{"class":237,"line":403},[621],{"type":18,"tag":34,"props":622,"children":624},{"emptyLinePlaceholder":623},true,[625],{"type":24,"value":626},"\n",{"type":18,"tag":34,"props":628,"children":630},{"class":237,"line":629},3,[631],{"type":18,"tag":34,"props":632,"children":634},{"style":633},"--shiki-default:#6A737D",[635],{"type":24,"value":636},"# 若成功，则出现类似下列内容的语句\n",{"type":18,"tag":34,"props":638,"children":640},{"class":237,"line":639},4,[641,646,651],{"type":18,"tag":34,"props":642,"children":643},{"style":242},[644],{"type":24,"value":645},"Hi",{"type":18,"tag":34,"props":647,"children":648},{"style":254},[649],{"type":24,"value":650}," 用户名!",{"type":18,"tag":34,"props":652,"children":653},{"style":254},[654],{"type":24,"value":655}," You've successfully authenticated, but GITEE.COM does not provide shell access.\n",{"type":18,"tag":657,"props":658,"children":659},"blockquote",{},[660,665,686],{"type":18,"tag":40,"props":661,"children":662},{},[663],{"type":24,"value":664},"错误提示：",{"type":18,"tag":40,"props":666,"children":667},{},[668,670,676,678,684],{"type":24,"value":669},"执行 ",{"type":18,"tag":232,"props":671,"children":673},{"className":672},[],[674],{"type":24,"value":675},"ssh -T git@gitee.com",{"type":24,"value":677}," 时出现连接认证失败，报错 ",{"type":18,"tag":232,"props":679,"children":681},{"className":680},[],[682],{"type":24,"value":683},"ssh_dispatch_run_fatal: Connection to gitee.com port 22: Broken pipe",{"type":24,"value":685},"：",{"type":18,"tag":278,"props":687,"children":688},{},[689,709],{"type":18,"tag":219,"props":690,"children":691},{},[692,694,700,702,707],{"type":24,"value":693},"原因：本地存在多组 SSH 密钥（例如 ",{"type":18,"tag":232,"props":695,"children":697},{"className":696},[],[698],{"type":24,"value":699},"id_ed25519",{"type":24,"value":701}," 用于 GitHub、",{"type":18,"tag":232,"props":703,"children":705},{"className":704},[],[706],{"type":24,"value":452},{"type":24,"value":708}," 用于 Gitee），默认连接未指定 Gitee 对应私钥，导致密钥不匹配、SSH 连接断开；",{"type":18,"tag":219,"props":710,"children":711},{},[712,714,720],{"type":24,"value":713},"解决方法：指定正确私钥执行 ",{"type":18,"tag":232,"props":715,"children":717},{"className":716},[],[718],{"type":24,"value":719},"ssh -T git@gitee.com -i ~\u002F.ssh\u002Fid_rsa",{"type":24,"value":721}," 后，连接认证成功。",{"type":18,"tag":27,"props":723,"children":725},{"id":724},"_15-添加远程仓库",[726],{"type":24,"value":727},"1.5 添加远程仓库",{"type":18,"tag":215,"props":729,"children":730},{},[731,744,813,825,1064],{"type":18,"tag":219,"props":732,"children":733},{},[734,736,739],{"type":24,"value":735},"复制远程仓库的SSH仓库路径；",{"type":18,"tag":264,"props":737,"children":738},{},[],{"type":18,"tag":184,"props":740,"children":743},{"alt":741,"src":742},"1775809989482","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775809989482.png",[],{"type":18,"tag":219,"props":745,"children":746},{},[747,749,770],{"type":24,"value":748},"执行下列指令将远程仓库绑定到本地；",{"type":18,"tag":278,"props":750,"children":751},{},[752,765],{"type":18,"tag":219,"props":753,"children":754},{},[755,757,763],{"type":24,"value":756},"远程仓库名称：默认使用 ",{"type":18,"tag":232,"props":758,"children":760},{"className":759},[],[761],{"type":24,"value":762},"origin",{"type":24,"value":764}," ，也可自定义",{"type":18,"tag":219,"props":766,"children":767},{},[768],{"type":24,"value":769},"远程仓库路径：从远端服务器获取",{"type":18,"tag":225,"props":771,"children":773},{"className":227,"code":772,"language":229,"meta":7,"style":7},"# git remote add 远程仓库名称 远程仓库路径\n    git remote add origin git@gitee.com:Couioly\u002Feducation-network.git\n",[774],{"type":18,"tag":232,"props":775,"children":776},{"__ignoreMap":7},[777,785],{"type":18,"tag":34,"props":778,"children":779},{"class":237,"line":238},[780],{"type":18,"tag":34,"props":781,"children":782},{"style":633},[783],{"type":24,"value":784},"# git remote add 远程仓库名称 远程仓库路径\n",{"type":18,"tag":34,"props":786,"children":787},{"class":237,"line":403},[788,793,798,803,808],{"type":18,"tag":34,"props":789,"children":790},{"style":242},[791],{"type":24,"value":792},"    git",{"type":18,"tag":34,"props":794,"children":795},{"style":254},[796],{"type":24,"value":797}," remote",{"type":18,"tag":34,"props":799,"children":800},{"style":254},[801],{"type":24,"value":802}," add",{"type":18,"tag":34,"props":804,"children":805},{"style":254},[806],{"type":24,"value":807}," origin",{"type":18,"tag":34,"props":809,"children":810},{"style":254},[811],{"type":24,"value":812}," git@gitee.com:Couioly\u002Feducation-network.git\n",{"type":18,"tag":219,"props":814,"children":815},{},[816,817,823],{"type":24,"value":669},{"type":18,"tag":232,"props":818,"children":820},{"className":819},[],[821],{"type":24,"value":822},"git remote",{"type":24,"value":824}," 指令可以查看当前远程仓库列表；",{"type":18,"tag":219,"props":826,"children":827},{},[828,830,855,1056,1059],{"type":24,"value":829},"推送到远程仓库的完整版命令：",{"type":18,"tag":225,"props":831,"children":833},{"className":227,"code":832,"language":229,"meta":7,"style":7},"git push [-f] [--set-upstream] [远程仓库名称[本地分支名][:远端分支名]]\n",[834],{"type":18,"tag":232,"props":835,"children":836},{"__ignoreMap":7},[837],{"type":18,"tag":34,"props":838,"children":839},{"class":237,"line":238},[840,845,850],{"type":18,"tag":34,"props":841,"children":842},{"style":242},[843],{"type":24,"value":844},"git",{"type":18,"tag":34,"props":846,"children":847},{"style":254},[848],{"type":24,"value":849}," push",{"type":18,"tag":34,"props":851,"children":852},{"style":346},[853],{"type":24,"value":854}," [-f] [--set-upstream] [远程仓库名称[本地分支名][:远端分支名]]\n",{"type":18,"tag":278,"props":856,"children":857},{},[858,898,909,951,986],{"type":18,"tag":219,"props":859,"children":860},{},[861,863],{"type":24,"value":862},"若远程分支名和本地分支名相同，则可以只写本地分支名；",{"type":18,"tag":225,"props":864,"children":866},{"className":227,"code":865,"language":229,"meta":7,"style":7},"# git push 远程仓库名称 本地分支名称\ngit push origin master\n",[867],{"type":18,"tag":232,"props":868,"children":869},{"__ignoreMap":7},[870,878],{"type":18,"tag":34,"props":871,"children":872},{"class":237,"line":238},[873],{"type":18,"tag":34,"props":874,"children":875},{"style":633},[876],{"type":24,"value":877},"# git push 远程仓库名称 本地分支名称\n",{"type":18,"tag":34,"props":879,"children":880},{"class":237,"line":403},[881,885,889,893],{"type":18,"tag":34,"props":882,"children":883},{"style":242},[884],{"type":24,"value":844},{"type":18,"tag":34,"props":886,"children":887},{"style":254},[888],{"type":24,"value":849},{"type":18,"tag":34,"props":890,"children":891},{"style":254},[892],{"type":24,"value":807},{"type":18,"tag":34,"props":894,"children":895},{"style":254},[896],{"type":24,"value":897}," master\n",{"type":18,"tag":219,"props":899,"children":900},{},[901,907],{"type":18,"tag":232,"props":902,"children":904},{"className":903},[],[905],{"type":24,"value":906},"-f",{"type":24,"value":908}," 表示强制，使用于在本地仓库和远程仓库发生冲突时，进行强制覆盖；",{"type":18,"tag":219,"props":910,"children":911},{},[912,918,920],{"type":18,"tag":232,"props":913,"children":915},{"className":914},[],[916],{"type":24,"value":917},"--set-upstream",{"type":24,"value":919}," 推送到远端的同时并且建立起和远端分支的关联关系；",{"type":18,"tag":225,"props":921,"children":923},{"className":227,"code":922,"language":229,"meta":7,"style":7},"git push --set-upstream origin master\n",[924],{"type":18,"tag":232,"props":925,"children":926},{"__ignoreMap":7},[927],{"type":18,"tag":34,"props":928,"children":929},{"class":237,"line":238},[930,934,938,943,947],{"type":18,"tag":34,"props":931,"children":932},{"style":242},[933],{"type":24,"value":844},{"type":18,"tag":34,"props":935,"children":936},{"style":254},[937],{"type":24,"value":849},{"type":18,"tag":34,"props":939,"children":940},{"style":248},[941],{"type":24,"value":942}," --set-upstream",{"type":18,"tag":34,"props":944,"children":945},{"style":254},[946],{"type":24,"value":807},{"type":18,"tag":34,"props":948,"children":949},{"style":254},[950],{"type":24,"value":897},{"type":18,"tag":219,"props":952,"children":953},{},[954,956,961,963],{"type":24,"value":955},"若",{"type":18,"tag":46,"props":957,"children":958},{},[959],{"type":24,"value":960},"当前分支已经和远端分支关联",{"type":24,"value":962},"，则可以省略分支名和远端名。",{"type":18,"tag":225,"props":964,"children":966},{"className":227,"code":965,"language":229,"meta":7,"style":7},"git push # 将master分支推送到已关联的远端分支\n",[967],{"type":18,"tag":232,"props":968,"children":969},{"__ignoreMap":7},[970],{"type":18,"tag":34,"props":971,"children":972},{"class":237,"line":238},[973,977,981],{"type":18,"tag":34,"props":974,"children":975},{"style":242},[976],{"type":24,"value":844},{"type":18,"tag":34,"props":978,"children":979},{"style":254},[980],{"type":24,"value":849},{"type":18,"tag":34,"props":982,"children":983},{"style":633},[984],{"type":24,"value":985}," # 将master分支推送到已关联的远端分支\n",{"type":18,"tag":219,"props":987,"children":988},{},[989,991],{"type":24,"value":990},"设置关联关系相关的指令：",{"type":18,"tag":225,"props":992,"children":994},{"className":227,"code":993,"language":229,"meta":7,"style":7},"git branch      # 查看本地仓库分支\ngit branch -vv  # 查看分支关联关系\ngit remote -vv  # 查看远程仓库分支\n",[995],{"type":18,"tag":232,"props":996,"children":997},{"__ignoreMap":7},[998,1015,1036],{"type":18,"tag":34,"props":999,"children":1000},{"class":237,"line":238},[1001,1005,1010],{"type":18,"tag":34,"props":1002,"children":1003},{"style":242},[1004],{"type":24,"value":844},{"type":18,"tag":34,"props":1006,"children":1007},{"style":254},[1008],{"type":24,"value":1009}," branch",{"type":18,"tag":34,"props":1011,"children":1012},{"style":633},[1013],{"type":24,"value":1014},"      # 查看本地仓库分支\n",{"type":18,"tag":34,"props":1016,"children":1017},{"class":237,"line":403},[1018,1022,1026,1031],{"type":18,"tag":34,"props":1019,"children":1020},{"style":242},[1021],{"type":24,"value":844},{"type":18,"tag":34,"props":1023,"children":1024},{"style":254},[1025],{"type":24,"value":1009},{"type":18,"tag":34,"props":1027,"children":1028},{"style":248},[1029],{"type":24,"value":1030}," -vv",{"type":18,"tag":34,"props":1032,"children":1033},{"style":633},[1034],{"type":24,"value":1035},"  # 查看分支关联关系\n",{"type":18,"tag":34,"props":1037,"children":1038},{"class":237,"line":629},[1039,1043,1047,1051],{"type":18,"tag":34,"props":1040,"children":1041},{"style":242},[1042],{"type":24,"value":844},{"type":18,"tag":34,"props":1044,"children":1045},{"style":254},[1046],{"type":24,"value":797},{"type":18,"tag":34,"props":1048,"children":1049},{"style":248},[1050],{"type":24,"value":1030},{"type":18,"tag":34,"props":1052,"children":1053},{"style":633},[1054],{"type":24,"value":1055},"  # 查看远程仓库分支\n",{"type":18,"tag":264,"props":1057,"children":1058},{},[],{"type":18,"tag":184,"props":1060,"children":1063},{"alt":1061,"src":1062},"1775812211632","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775812211632.png",[],{"type":18,"tag":219,"props":1065,"children":1066},{},[1067,1072],{"type":18,"tag":46,"props":1068,"children":1069},{},[1070],{"type":24,"value":1071},"删除远程文件（本地保留）",{"type":18,"tag":278,"props":1073,"children":1074},{},[1075,1109],{"type":18,"tag":219,"props":1076,"children":1077},{},[1078,1080],{"type":24,"value":1079},"删除文件",{"type":18,"tag":225,"props":1081,"children":1083},{"className":227,"code":1082,"language":229,"meta":7,"style":7},"git rm --cached 文件名\n",[1084],{"type":18,"tag":232,"props":1085,"children":1086},{"__ignoreMap":7},[1087],{"type":18,"tag":34,"props":1088,"children":1089},{"class":237,"line":238},[1090,1094,1099,1104],{"type":18,"tag":34,"props":1091,"children":1092},{"style":242},[1093],{"type":24,"value":844},{"type":18,"tag":34,"props":1095,"children":1096},{"style":254},[1097],{"type":24,"value":1098}," rm",{"type":18,"tag":34,"props":1100,"children":1101},{"style":248},[1102],{"type":24,"value":1103}," --cached",{"type":18,"tag":34,"props":1105,"children":1106},{"style":254},[1107],{"type":24,"value":1108}," 文件名\n",{"type":18,"tag":219,"props":1110,"children":1111},{},[1112,1114,1146,1149,1155],{"type":24,"value":1113},"删除文件夹（必须加 -r）",{"type":18,"tag":225,"props":1115,"children":1117},{"className":227,"code":1116,"language":229,"meta":7,"style":7},"git rm --cached -r 文件夹名\n",[1118],{"type":18,"tag":232,"props":1119,"children":1120},{"__ignoreMap":7},[1121],{"type":18,"tag":34,"props":1122,"children":1123},{"class":237,"line":238},[1124,1128,1132,1136,1141],{"type":18,"tag":34,"props":1125,"children":1126},{"style":242},[1127],{"type":24,"value":844},{"type":18,"tag":34,"props":1129,"children":1130},{"style":254},[1131],{"type":24,"value":1098},{"type":18,"tag":34,"props":1133,"children":1134},{"style":248},[1135],{"type":24,"value":1103},{"type":18,"tag":34,"props":1137,"children":1138},{"style":248},[1139],{"type":24,"value":1140}," -r",{"type":18,"tag":34,"props":1142,"children":1143},{"style":254},[1144],{"type":24,"value":1145}," 文件夹名\n",{"type":18,"tag":264,"props":1147,"children":1148},{},[],{"type":18,"tag":232,"props":1150,"children":1152},{"className":1151},[],[1153],{"type":24,"value":1154},"--cached",{"type":24,"value":1156}," 是关键！只删远程，不删本地。删除后再次执行提交-推送即可达到删除远程文件的目的。",{"type":18,"tag":27,"props":1158,"children":1160},{"id":1159},"_16-克隆远程仓库",[1161],{"type":24,"value":1162},"1.6 克隆远程仓库",{"type":18,"tag":40,"props":1164,"children":1165},{},[1166,1168,1174],{"type":24,"value":1167},"如果已存在一个远端仓库，我们可以直接 ",{"type":18,"tag":232,"props":1169,"children":1171},{"className":1170},[],[1172],{"type":24,"value":1173},"clone",{"type":24,"value":1175}," 到本地。指令如下：",{"type":18,"tag":225,"props":1177,"children":1179},{"className":227,"code":1178,"language":229,"meta":7,"style":7},"# git clone \u003C仓库路径> [本地目录(可选)]\ngit clone git@gitee.com:Couioly\u002Feducation-network.git\n",[1180],{"type":18,"tag":232,"props":1181,"children":1182},{"__ignoreMap":7},[1183,1191],{"type":18,"tag":34,"props":1184,"children":1185},{"class":237,"line":238},[1186],{"type":18,"tag":34,"props":1187,"children":1188},{"style":633},[1189],{"type":24,"value":1190},"# git clone \u003C仓库路径> [本地目录(可选)]\n",{"type":18,"tag":34,"props":1192,"children":1193},{"class":237,"line":403},[1194,1198,1203],{"type":18,"tag":34,"props":1195,"children":1196},{"style":242},[1197],{"type":24,"value":844},{"type":18,"tag":34,"props":1199,"children":1200},{"style":254},[1201],{"type":24,"value":1202}," clone",{"type":18,"tag":34,"props":1204,"children":1205},{"style":254},[1206],{"type":24,"value":812},{"type":18,"tag":27,"props":1208,"children":1210},{"id":1209},"_17-远程仓库中抓取和拉取",[1211],{"type":24,"value":1212},"1.7 远程仓库中抓取和拉取",{"type":18,"tag":40,"props":1214,"children":1215},{},[1216],{"type":24,"value":1217},"远程分支和本地的分支一样，我们可以进行merge操作，只是需要先把远端仓库里的更新都下载到本地，再进行操作。",{"type":18,"tag":278,"props":1219,"children":1220},{},[1221,1269,1302,1345],{"type":18,"tag":219,"props":1222,"children":1223},{},[1224,1229,1230],{"type":18,"tag":46,"props":1225,"children":1226},{},[1227],{"type":24,"value":1228},"抓取（fetch）命令形式",{"type":24,"value":685},{"type":18,"tag":225,"props":1231,"children":1233},{"className":227,"code":1232,"language":229,"meta":7,"style":7},"git fetch [remote name] [branch name]\n",[1234],{"type":18,"tag":232,"props":1235,"children":1236},{"__ignoreMap":7},[1237],{"type":18,"tag":34,"props":1238,"children":1239},{"class":237,"line":238},[1240,1244,1249,1254,1259,1264],{"type":18,"tag":34,"props":1241,"children":1242},{"style":242},[1243],{"type":24,"value":844},{"type":18,"tag":34,"props":1245,"children":1246},{"style":254},[1247],{"type":24,"value":1248}," fetch",{"type":18,"tag":34,"props":1250,"children":1251},{"style":346},[1252],{"type":24,"value":1253}," [remote ",{"type":18,"tag":34,"props":1255,"children":1256},{"style":254},[1257],{"type":24,"value":1258},"name]",{"type":18,"tag":34,"props":1260,"children":1261},{"style":346},[1262],{"type":24,"value":1263}," [branch ",{"type":18,"tag":34,"props":1265,"children":1266},{"style":254},[1267],{"type":24,"value":1268},"name]\n",{"type":18,"tag":219,"props":1270,"children":1271},{},[1272,1274],{"type":24,"value":1273},"说明：",{"type":18,"tag":278,"props":1275,"children":1276},{},[1277,1297],{"type":18,"tag":219,"props":1278,"children":1279},{},[1280,1282,1287,1289,1295],{"type":24,"value":1281},"抓取指令就是将仓库里的更新都抓取到本地，",{"type":18,"tag":46,"props":1283,"children":1284},{},[1285],{"type":24,"value":1286},"不会进行合并",{"type":24,"value":1288},"，需再次执行 ",{"type":18,"tag":232,"props":1290,"children":1292},{"className":1291},[],[1293],{"type":24,"value":1294},"git merge 远程仓库\u002F远程分支名",{"type":24,"value":1296}," 进行合并",{"type":18,"tag":219,"props":1298,"children":1299},{},[1300],{"type":24,"value":1301},"如果不指定远端名称和分支名，则抓取所有分支",{"type":18,"tag":219,"props":1303,"children":1304},{},[1305,1310],{"type":18,"tag":46,"props":1306,"children":1307},{},[1308],{"type":24,"value":1309},"拉取（pull）命令形式：",{"type":18,"tag":225,"props":1311,"children":1313},{"className":227,"code":1312,"language":229,"meta":7,"style":7},"git pull [remote name] [branch name]\n",[1314],{"type":18,"tag":232,"props":1315,"children":1316},{"__ignoreMap":7},[1317],{"type":18,"tag":34,"props":1318,"children":1319},{"class":237,"line":238},[1320,1324,1329,1333,1337,1341],{"type":18,"tag":34,"props":1321,"children":1322},{"style":242},[1323],{"type":24,"value":844},{"type":18,"tag":34,"props":1325,"children":1326},{"style":254},[1327],{"type":24,"value":1328}," pull",{"type":18,"tag":34,"props":1330,"children":1331},{"style":346},[1332],{"type":24,"value":1253},{"type":18,"tag":34,"props":1334,"children":1335},{"style":254},[1336],{"type":24,"value":1258},{"type":18,"tag":34,"props":1338,"children":1339},{"style":346},[1340],{"type":24,"value":1263},{"type":18,"tag":34,"props":1342,"children":1343},{"style":254},[1344],{"type":24,"value":1268},{"type":18,"tag":219,"props":1346,"children":1347},{},[1348,1349],{"type":24,"value":1273},{"type":18,"tag":278,"props":1350,"children":1351},{},[1352,1362],{"type":18,"tag":219,"props":1353,"children":1354},{},[1355,1357],{"type":24,"value":1356},"拉取指令就是将远端仓库的修改拉到本地并自动进行合并，",{"type":18,"tag":46,"props":1358,"children":1359},{},[1360],{"type":24,"value":1361},"等同于 fetch + merge",{"type":18,"tag":219,"props":1363,"children":1364},{},[1365],{"type":24,"value":1366},"如果不指定远端名称和分支名，则抓取所有并更新当前分支",{"type":18,"tag":27,"props":1368,"children":1370},{"id":1369},"_18-解决合并冲突",[1371],{"type":24,"value":1372},"1.8 解决合并冲突",{"type":18,"tag":40,"props":1374,"children":1375},{},[1376,1381],{"type":18,"tag":46,"props":1377,"children":1378},{},[1379],{"type":24,"value":1380},"冲突产生原因",{"type":24,"value":1382},"：在一段时间内，A、B用户修改了同一个文件，且修改了同一行位置的代码，此时会发生合并冲突。",{"type":18,"tag":40,"props":1384,"children":1385},{},[1386,1391,1393,1398],{"type":18,"tag":46,"props":1387,"children":1388},{},[1389],{"type":24,"value":1390},"冲突场景流程",{"type":24,"value":1392},"：A用户在本地修改代码后优先推送到远程仓库，此时B用户在本地修订代码，提交到本地仓库后，也需要推送到远程仓库。由于B用户晚于A用户推送，故",{"type":18,"tag":46,"props":1394,"children":1395},{},[1396],{"type":24,"value":1397},"需要先拉取远程仓库的提交，经过合并后才能推送到远端分支",{"type":24,"value":1399},"（在B用户拉取代码时，因为A、B用户同一段时间修改了同一个文件的相同位置代码，故会发生合并冲突）",{"type":18,"tag":40,"props":1401,"children":1402},{},[1403],{"type":18,"tag":184,"props":1404,"children":1407},{"alt":1405,"src":1406},"1775814506803","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775814506803.png",[],{"type":18,"tag":40,"props":1409,"children":1410},{},[1411,1413,1418],{"type":24,"value":1412},"远程分支也是分支，所以",{"type":18,"tag":46,"props":1414,"children":1415},{},[1416],{"type":24,"value":1417},"合并时冲突的解决方式也和解决本地分支冲突相同",{"type":24,"value":1419},"，在此不再赘述。",{"type":18,"tag":19,"props":1421,"children":1423},{"id":1422},"_2-pycharm-中使用-git",[1424],{"type":24,"value":1425},"2 PyCharm 中使用 Git",{"type":18,"tag":27,"props":1427,"children":1429},{"id":1428},"_21-在pycharm中配置git",[1430],{"type":24,"value":1431},"2.1 在PyCharm中配置Git",{"type":18,"tag":40,"props":1433,"children":1434},{},[1435],{"type":24,"value":1436},"安装好PyCharm后，如果Git安装在默认路径下，那么PyCharm会自动找到git的位置，如果更改了Git的安装位置则需要手动配置下Git的路径。选择File→Settings打开设置窗口，找到Version Control下的git选项：",{"type":18,"tag":40,"props":1438,"children":1439},{},[1440],{"type":18,"tag":184,"props":1441,"children":1444},{"alt":1442,"src":1443},"1775815884830","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775815884830.png",[],{"type":18,"tag":27,"props":1446,"children":1448},{"id":1447},"_22-在pycharm中操作git",[1449],{"type":24,"value":1450},"2.2 在PyCharm中操作Git",{"type":18,"tag":215,"props":1452,"children":1453},{},[1454,1475,1504,1517,1594],{"type":18,"tag":219,"props":1455,"children":1456},{},[1457,1459,1465,1467,1470],{"type":24,"value":1458},"创建一个远程仓库，此处以 ",{"type":18,"tag":232,"props":1460,"children":1462},{"className":1461},[],[1463],{"type":24,"value":1464},"AIHeartCrisis",{"type":24,"value":1466}," 为例；",{"type":18,"tag":264,"props":1468,"children":1469},{},[],{"type":18,"tag":184,"props":1471,"children":1474},{"alt":1472,"src":1473},"1775817252203","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775817252203.png",[],{"type":18,"tag":219,"props":1476,"children":1477},{},[1478,1480,1486,1488,1494,1496,1499],{"type":24,"value":1479},"打开本地 ",{"type":18,"tag":232,"props":1481,"children":1483},{"className":1482},[],[1484],{"type":24,"value":1485},"HeartCrisisAPI",{"type":24,"value":1487}," 项目，将本地项目初始化为Git项目，相当于执行了 ",{"type":18,"tag":232,"props":1489,"children":1491},{"className":1490},[],[1492],{"type":24,"value":1493},"git init",{"type":24,"value":1495}," 指令；",{"type":18,"tag":264,"props":1497,"children":1498},{},[],{"type":18,"tag":184,"props":1500,"children":1503},{"alt":1501,"src":1502},"1775816649707","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775816649707.png",[],{"type":18,"tag":219,"props":1505,"children":1506},{},[1507,1509,1512],{"type":24,"value":1508},"选择需要变更为Git项目的项目根目录文件夹；",{"type":18,"tag":264,"props":1510,"children":1511},{},[],{"type":18,"tag":184,"props":1513,"children":1516},{"alt":1514,"src":1515},"1775817440166","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775817440166.png",[],{"type":18,"tag":219,"props":1518,"children":1519},{},[1520,1522,1528,1530,1536,1538,1544,1546,1552,1554,1560,1562,1568,1570,1576,1578,1584,1586,1589],{"type":24,"value":1521},"点击左侧栏中的 ",{"type":18,"tag":232,"props":1523,"children":1525},{"className":1524},[],[1526],{"type":24,"value":1527},"commit",{"type":24,"value":1529}," 按钮，勾选需要提交到仓库的文件，因为此处配置了 ",{"type":18,"tag":232,"props":1531,"children":1533},{"className":1532},[],[1534],{"type":24,"value":1535},".gitignore",{"type":24,"value":1537}," 文件，所以可以一键勾选，该步骤类似于 ",{"type":18,"tag":232,"props":1539,"children":1541},{"className":1540},[],[1542],{"type":24,"value":1543},"git add .",{"type":24,"value":1545}," 指令；然后输入提交注释，该步骤类似于 ",{"type":18,"tag":232,"props":1547,"children":1549},{"className":1548},[],[1550],{"type":24,"value":1551},"git commit -m ''",{"type":24,"value":1553}," 指令；接下来点击 ",{"type":18,"tag":232,"props":1555,"children":1557},{"className":1556},[],[1558],{"type":24,"value":1559},"commit and push",{"type":24,"value":1561}," 首次推送远程仓库会遇到需要绑定远程仓库的情况，此处点击 ",{"type":18,"tag":232,"props":1563,"children":1565},{"className":1564},[],[1566],{"type":24,"value":1567},"Define remote",{"type":24,"value":1569}," ，在打开的窗口中配置远程仓库信息，最后点击 ",{"type":18,"tag":232,"props":1571,"children":1573},{"className":1572},[],[1574],{"type":24,"value":1575},"OK",{"type":24,"value":1577}," 和 ",{"type":18,"tag":232,"props":1579,"children":1581},{"className":1580},[],[1582],{"type":24,"value":1583},"Push",{"type":24,"value":1585},"即可完成推送操作。",{"type":18,"tag":264,"props":1587,"children":1588},{},[],{"type":18,"tag":184,"props":1590,"children":1593},{"alt":1591,"src":1592},"1775817950527","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775817950527.png",[],{"type":18,"tag":219,"props":1595,"children":1596},{},[1597,1599,1602],{"type":24,"value":1598},"回到远程仓库刷新，发现成功推送！",{"type":18,"tag":264,"props":1600,"children":1601},{},[],{"type":18,"tag":184,"props":1603,"children":1606},{"alt":1604,"src":1605},"1775818570340","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775818570340.png",[],{"type":18,"tag":27,"props":1608,"children":1610},{"id":1609},"_23-克隆远程仓库到pycharm",[1611],{"type":24,"value":1612},"2.3 克隆远程仓库到PyCharm",{"type":18,"tag":215,"props":1614,"children":1615},{},[1616,1653],{"type":18,"tag":219,"props":1617,"children":1618},{},[1619,1621,1627,1629,1635,1637,1643,1645,1648],{"type":24,"value":1620},"通过 ",{"type":18,"tag":232,"props":1622,"children":1624},{"className":1623},[],[1625],{"type":24,"value":1626},"file",{"type":24,"value":1628}," - ",{"type":18,"tag":232,"props":1630,"children":1632},{"className":1631},[],[1633],{"type":24,"value":1634},"Project from Version Control",{"type":24,"value":1636}," 打开克隆窗口，将远程仓库的SSH路径复制到URL中，点击克隆 ",{"type":18,"tag":232,"props":1638,"children":1640},{"className":1639},[],[1641],{"type":24,"value":1642},"Clone",{"type":24,"value":1644},"；",{"type":18,"tag":264,"props":1646,"children":1647},{},[],{"type":18,"tag":184,"props":1649,"children":1652},{"alt":1650,"src":1651},"1775819381563","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775819381563.png",[],{"type":18,"tag":219,"props":1654,"children":1655},{},[1656,1658,1661],{"type":24,"value":1657},"下图为克隆后的效果图，它将在一个新的窗口中展示；",{"type":18,"tag":264,"props":1659,"children":1660},{},[],{"type":18,"tag":184,"props":1662,"children":1665},{"alt":1663,"src":1664},"1775819841223","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775819841223.png",[],{"type":18,"tag":27,"props":1667,"children":1669},{"id":1668},"_24-解决冲突",[1670],{"type":24,"value":1671},"2.4 解决冲突",{"type":18,"tag":215,"props":1673,"children":1674},{},[1675,1704,1717,1774,1795],{"type":18,"tag":219,"props":1676,"children":1677},{},[1678,1680,1686,1688,1694,1696,1699],{"type":24,"value":1679},"假设此时我在原来的项目中添加了一个用于展示登录页面的接口 ",{"type":18,"tag":232,"props":1681,"children":1683},{"className":1682},[],[1684],{"type":24,"value":1685},"api\u002Flogin-page",{"type":24,"value":1687},"；与此同时，在克隆项目中添加了一个用于展示主页页面的接口 ",{"type":18,"tag":232,"props":1689,"children":1691},{"className":1690},[],[1692],{"type":24,"value":1693},"api\u002Findex-page",{"type":24,"value":1695},"，它们属于同一文件下同一位置，如下图所示：",{"type":18,"tag":264,"props":1697,"children":1698},{},[],{"type":18,"tag":184,"props":1700,"children":1703},{"alt":1701,"src":1702},"1775820923148","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775820923148.png",[],{"type":18,"tag":219,"props":1705,"children":1706},{},[1707,1709,1712],{"type":24,"value":1708},"此时我先推送原项目的修改内容至远程仓库，可见可以成功推送；",{"type":18,"tag":264,"props":1710,"children":1711},{},[],{"type":18,"tag":184,"props":1713,"children":1716},{"alt":1714,"src":1715},"1775821364173","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775821364173.png",[],{"type":18,"tag":219,"props":1718,"children":1719},{},[1720,1722,1727,1729,1734,1735,1741,1743,1749,1751,1757,1759,1764,1766,1769],{"type":24,"value":1721},"接下来在克隆项目中我先进行提交 ",{"type":18,"tag":232,"props":1723,"children":1725},{"className":1724},[],[1726],{"type":24,"value":1527},{"type":24,"value":1728},"，然后点击 ",{"type":18,"tag":232,"props":1730,"children":1732},{"className":1731},[],[1733],{"type":24,"value":12},{"type":24,"value":1628},{"type":18,"tag":232,"props":1736,"children":1738},{"className":1737},[],[1739],{"type":24,"value":1740},"Pull",{"type":24,"value":1742}," 后，它将提示处理 ",{"type":18,"tag":232,"props":1744,"children":1746},{"className":1745},[],[1747],{"type":24,"value":1748},"Merge",{"type":24,"value":1750}," 异常的窗口，由于刚刚接触，我们先不在此处修改，直接关闭该窗口，接着你将看到版本控制区显示了 ",{"type":18,"tag":232,"props":1752,"children":1754},{"className":1753},[],[1755],{"type":24,"value":1756},"fetch",{"type":24,"value":1758}," 到的记录，同时导致 ",{"type":18,"tag":232,"props":1760,"children":1762},{"className":1761},[],[1763],{"type":24,"value":1748},{"type":24,"value":1765}," 异常的文件将报错高亮显示，如下图；",{"type":18,"tag":264,"props":1767,"children":1768},{},[],{"type":18,"tag":184,"props":1770,"children":1773},{"alt":1771,"src":1772},"1775821690591","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775821690591.png",[],{"type":18,"tag":219,"props":1775,"children":1776},{},[1777,1779,1785,1787,1790],{"type":24,"value":1778},"修改合并出错的语句块，修改完成后将该文件 ",{"type":18,"tag":232,"props":1780,"children":1782},{"className":1781},[],[1783],{"type":24,"value":1784},"add",{"type":24,"value":1786}," 到缓存区，如下图所示：",{"type":18,"tag":264,"props":1788,"children":1789},{},[],{"type":18,"tag":184,"props":1791,"children":1794},{"alt":1792,"src":1793},"1775822145279","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775822145279.png",[],{"type":18,"tag":219,"props":1796,"children":1797},{},[1798,1800,1803,1808,1811],{"type":24,"value":1799},"最后根据正常推送逻辑进行远程仓库推送即可",{"type":18,"tag":264,"props":1801,"children":1802},{},[],{"type":18,"tag":184,"props":1804,"children":1807},{"alt":1805,"src":1806},"1775822259230","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775822259230.png",[],{"type":18,"tag":264,"props":1809,"children":1810},{},[],{"type":18,"tag":184,"props":1812,"children":1815},{"alt":1813,"src":1814},"1775822300039","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775822300039.png",[],{"type":18,"tag":27,"props":1817,"children":1819},{"id":1818},"_25-其他git操作",[1820],{"type":24,"value":1821},"2.5 其他Git操作",{"type":18,"tag":215,"props":1823,"children":1824},{},[1825,1838,1888],{"type":18,"tag":219,"props":1826,"children":1827},{},[1828,1830,1833],{"type":24,"value":1829},"添加分支操作：打开Git的Log页面，直接点击需要创建分支的位置，右键选择新建分支；",{"type":18,"tag":264,"props":1831,"children":1832},{},[],{"type":18,"tag":184,"props":1834,"children":1837},{"alt":1835,"src":1836},"1775822921996","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775822921996.png",[],{"type":18,"tag":219,"props":1839,"children":1840},{},[1841,1843,1849,1851,1857,1859,1864,1866,1871,1873,1879,1880,1883],{"type":24,"value":1842},"合并分支操作：假设现在需要将 ",{"type":18,"tag":232,"props":1844,"children":1846},{"className":1845},[],[1847],{"type":24,"value":1848},"dev",{"type":24,"value":1850}," 分支合并至 ",{"type":18,"tag":232,"props":1852,"children":1854},{"className":1853},[],[1855],{"type":24,"value":1856},"master",{"type":24,"value":1858}," 分支，需先将当前分支切换至 ",{"type":18,"tag":232,"props":1860,"children":1862},{"className":1861},[],[1863],{"type":24,"value":1856},{"type":24,"value":1865},"，然后右击 ",{"type":18,"tag":232,"props":1867,"children":1869},{"className":1868},[],[1870],{"type":24,"value":1848},{"type":24,"value":1872}," 选择 ",{"type":18,"tag":232,"props":1874,"children":1876},{"className":1875},[],[1877],{"type":24,"value":1878},"Merge 'dev' into 'master'",{"type":24,"value":1644},{"type":18,"tag":264,"props":1881,"children":1882},{},[],{"type":18,"tag":184,"props":1884,"children":1887},{"alt":1885,"src":1886},"1775823212025","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775823212025.png",[],{"type":18,"tag":219,"props":1889,"children":1890},{},[1891,1893,1896],{"type":24,"value":1892},"修改PyCharm的Terminal为Git-Bash",{"type":18,"tag":264,"props":1894,"children":1895},{},[],{"type":18,"tag":184,"props":1897,"children":1900},{"alt":1898,"src":1899},"1775824100487","\u002Fimages\u002Fblog\u002Fgit-advanced\u002F1775824100487.png",[],{"type":18,"tag":19,"props":1902,"children":1904},{"id":1903},"_3-git铁令",[1905],{"type":24,"value":1906},"3 Git铁令",{"type":18,"tag":278,"props":1908,"children":1909},{},[1910,1918,1926],{"type":18,"tag":219,"props":1911,"children":1912},{},[1913],{"type":18,"tag":46,"props":1914,"children":1915},{},[1916],{"type":24,"value":1917},"切换分支前先提交本地的修改",{"type":18,"tag":219,"props":1919,"children":1920},{},[1921],{"type":18,"tag":46,"props":1922,"children":1923},{},[1924],{"type":24,"value":1925},"任何修改文件及时提交",{"type":18,"tag":219,"props":1927,"children":1928},{},[1929],{"type":18,"tag":46,"props":1930,"children":1931},{},[1932],{"type":24,"value":1933},"遇到任何问题都不要删除文件目录",{"type":18,"tag":1935,"props":1936,"children":1937},"style",{},[1938],{"type":24,"value":1939},"html .default .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}html .shiki span {color: var(--shiki-default);background: var(--shiki-default-bg);font-style: var(--shiki-default-font-style);font-weight: var(--shiki-default-font-weight);text-decoration: var(--shiki-default-text-decoration);}",{"title":7,"searchDepth":403,"depth":403,"links":1941},[1942,1953,1960],{"id":21,"depth":403,"text":25,"children":1943},[1944,1946,1947,1948,1949,1950,1951,1952],{"id":29,"depth":629,"text":1945},"1.1 常用的托管服务 远程仓库",{"id":162,"depth":629,"text":165},{"id":191,"depth":629,"text":194},{"id":210,"depth":629,"text":213},{"id":724,"depth":629,"text":727},{"id":1159,"depth":629,"text":1162},{"id":1209,"depth":629,"text":1212},{"id":1369,"depth":629,"text":1372},{"id":1422,"depth":403,"text":1425,"children":1954},[1955,1956,1957,1958,1959],{"id":1428,"depth":629,"text":1431},{"id":1447,"depth":629,"text":1450},{"id":1609,"depth":629,"text":1612},{"id":1668,"depth":629,"text":1671},{"id":1818,"depth":629,"text":1821},{"id":1903,"depth":403,"text":1906},"markdown","content:blog:2026-05-05-GitAdvanced.md","content","blog\u002F2026-05-05-GitAdvanced.md","blog\u002F2026-05-05-GitAdvanced","md",1780801017578]