[{"data":1,"prerenderedAt":1095},["ShallowReactive",2],{"post-git-learning":3,"home":1073},{"id":4,"title":5,"body":6,"date":1062,"description":1063,"extension":1064,"meta":1065,"navigation":1066,"path":1067,"seo":1068,"stem":1069,"tags":1070,"__hash__":1072},"blog\u002Fblog\u002Fgit-learning.md","Git学习记录",{"type":7,"value":8,"toc":1039},"minimark",[9,23,27,82,86,90,107,217,220,225,321,324,330,336,339,365,370,373,439,442,454,457,519,521,526,530,602,604,617,631,653,659,662,668,671,675,698,701,708,714,732,738,745,751,755,758,764,767,770,773,787,801,803,809,822,827,831,838,843,846,849,852,893,896,906,912,919,925,932,934,945,948,987,990,1013,1016,1036],[10,11,12],"blockquote",{},[13,14,15,16],"p",{},"git官网书籍",[17,18,22],"a",{"href":19,"rel":20},"https:\u002F\u002Fgit-scm.com\u002Fbook\u002Fzh\u002Fv2",[21],"nofollow","《Pro Git》",[24,25,26],"h2",{"id":26},"目录",[28,29,30,57,68,79],"ul",{},[31,32,33,34],"li",{},"基础\n",[28,35,36,39,42,45,48,51,54],{},[31,37,38],{},"更新与提交：add, status, diff, commit, rm, mv",[31,40,41],{},"提交历史：log",[31,43,44],{},"撤销：restore",[31,46,47],{},"远程仓库: remote",[31,49,50],{},"标签：tag",[31,52,53],{},"别名",[31,55,56],{},".gitingore",[31,58,59,60],{},"分支\n",[28,61,62,65],{},[31,63,64],{},"远程分支",[31,66,67],{},"变基：rebase",[31,69,70,71],{},"原理\n",[28,72,73,76],{},[31,74,75],{},"对象",[31,77,78],{},"引用",[31,80,81],{},"...",[24,83,85],{"id":84},"git基础","Git基础",[87,88,89],"h3",{"id":89},"更新与提交",[13,91,92,93,100,101,106],{},"工作目录下的文件只有两种状态：",[94,95,96],"em",{},[97,98,99],"strong",{},"已跟踪",", ",[94,102,103],{},[97,104,105],{},"未跟踪","，对于已跟踪的文件，只有暂存的文件才会被提交",[28,108,109,116,122,140,157,201],{},[31,110,111,115],{},[112,113,114],"code",{},"git status","查看状态",[31,117,118,121],{},[112,119,120],{},"git add \u003Cfile>","跟踪文件以及将文件暂存(staged)",[31,123,124,127,128],{},[112,125,126],{},"git diff","查看未暂存的修改",[28,129,130],{},[31,131,132,135,136,139],{},[112,133,134],{},"--staged","或",[112,137,138],{},"--cached","查看暂存文件与上次提交的文件差异",[31,141,142,145,146,148,149],{},[112,143,144],{},"git commit","提交文件，提交前",[112,147,114],{},"下确认所需文件是否在暂存区",[28,150,151],{},[31,152,153,156],{},[112,154,155],{},"-a","可跳过暂存阶段，直接将跟踪文件暂存提交",[31,158,159,162,163,166,167,170,171,174,175,179,180,183,184,187,188],{},[112,160,161],{},"git rm \u003Cfile>","删除已跟踪文件。相当于",[112,164,165],{},"rm \u003Cfile>","后，",[112,168,169],{},"git add","进暂存区，与创建文件后",[112,172,173],{},"git add\u003Cfile>","对应",[176,177,178],"del",{},"个人理解，可能有误","。",[181,182],"br",{},"当",[112,185,186],{},"\u003Cfile>","修改过或已暂存后，可使用：",[28,189,190,196],{},[31,191,192,195],{},[112,193,194],{},"-f","安全特性，防止未添加到快照的数据误删",[31,197,198,200],{},[112,199,138],{},"仅仅从暂存区删除，文件还在",[31,202,203,206,207],{},[112,204,205],{},"git mv \u003Cfile_a> \u003Cfile_b>","等价于：",[208,209,214],"pre",{"className":210,"code":212,"language":213},[211],"language-text","$ mv file_a file_b\n$ git rm file_a\n$ git add file_b\n","text",[112,215,212],{"__ignoreMap":216},"",[87,218,219],{"id":219},"查看提交历史",[13,221,222],{},[112,223,224],{},"git log",[28,226,227,240,246,263,269,275,285,303,312,318],{},[31,228,229,135,232,235,236,239],{},[112,230,231],{},"-p",[112,233,234],{},"--patch","，以",[97,237,238],{},"补丁","的格式输出每次提交的所引入的差异",[31,241,242,245],{},[112,243,244],{},"--stat","每次提交的简略统计信息",[31,247,248,251,252,255,256,255,259,262],{},[112,249,250],{},"--pretty=oneline","一行显示一条提交，其他样式",[112,253,254],{},"--pretty=short","，",[112,257,258],{},"--pretty=full",[112,260,261],{},"--pretty=fuller","仅信息详细程度不同",[31,264,265,268],{},[112,266,267],{},"--pretty=format","自定义输出格式",[31,270,271,274],{},[112,272,273],{},"--graph","更形象的显示分支",[31,276,277,280,281,284],{},[112,278,279],{},"-\u003Cn>","如",[112,282,283],{},"git log -2","显示两条记录",[31,286,287,290,291,294,295,298,299,302],{},[112,288,289],{},"--since=\u003Ctime_a>","与",[112,292,293],{},"--until=\u003Ctime_b>"," ，显示从",[112,296,297],{},"time_a","到",[112,300,301],{},"time_b","的提交",[31,304,305,290,308,311],{},[112,306,307],{},"--after=\u003Ctime_a>",[112,309,310],{},"--before=\u003Ctime_b>","与上条相同",[31,313,314,317],{},[112,315,316],{},"-S \u003Cstring>","过滤器，只显示增加或删除该字符串的提交",[31,319,320],{},"其他。。。",[13,322,323],{},"比如：",[208,325,328],{"className":326,"code":327,"language":213},[211],"$ git log --pretty=\"%h - %s\" --author='Junio C Hamano' --since=\"2008-10-01\" \\\n   --before=\"2008-11-01\" --no-merges -- t\u002F\n",[112,329,327],{"__ignoreMap":216},[13,331,332,335],{},[112,333,334],{},"-- t\u002F","指对t文件夹的提交",[87,337,338],{"id":338},"撤销操作",[28,340,341,353,359],{},[31,342,343,346,347],{},[112,344,345],{},"git commit --amend","重新提交，替代上一次的提交结果，如：",[208,348,351],{"className":349,"code":350,"language":213},[211],"$ git commit -m 'initial commit'\n$ git add forgotten_file\n$ git commit --amend\n",[112,352,350],{"__ignoreMap":216},[31,354,355,358],{},[112,356,357],{},"git restore --staged \u003Cfile>","取消暂存",[31,360,361,364],{},[112,362,363],{},"git restore \u003Cfile>","撤销修改",[13,366,367],{},[176,368,369],{},"上两条与《Pro Git》不同，可能更新了",[87,371,372],{"id":372},"远程仓库",[28,374,375,424,433],{},[31,376,377,380,381],{},[112,378,379],{},"git remote","查看远程仓库\n",[28,382,383,389,395,405,411],{},[31,384,385,388],{},[112,386,387],{},"-v","显示远程仓库以及url",[31,390,391,394],{},[112,392,393],{},"add \u003Cshortname> \u003Curl>","添加新的远程仓库并指定简写",[31,396,397,400,401,404],{},[112,398,399],{},"show \u003Cremote>","查看",[112,402,403],{},"remote","的信息",[31,406,407,410],{},[112,408,409],{},"rename \u003Cremote> \u003Cnew_remote>","远程仓库重命名",[31,412,413,416,417,420,421,423],{},[112,414,415],{},"remove \u003Cremote>","或者",[112,418,419],{},"rm \u003Cremote>","移除",[112,422,403],{},"仓库",[31,425,426,429,430,432],{},[112,427,428],{},"git fetch \u003Cremote>","访问",[112,431,403],{},"仓库，拉取没有的数据",[31,434,435,438],{},[112,436,437],{},"git push \u003Creomte> \u003Cbranch>","推送",[87,440,441],{"id":441},"标签",[13,443,444,447,448,135,451,179],{},[112,445,446],{},"git tag","列出所有标签可带",[112,449,450],{},"-l",[112,452,453],{},"--list",[13,455,456],{},"而标签分为轻量与附注，附注标签包含打标签人的信息、日期等，另外可以附加标签信息",[28,458,459,465,471,484,490,500,513],{},[31,460,461,464],{},[112,462,463],{},"git tag \u003Ctagname>","创建轻量标签",[31,466,467,470],{},[112,468,469],{},"git tag -a \u003Ctagname> -m \u003Ctag_message>","创建附注标签",[31,472,473,476,477,480,481,483],{},[112,474,475],{},"git tag -a \u003Ctagname> \u003Ccommit>","为",[112,478,479],{},"commit","打标签，",[112,482,479],{},"为提交的完整或部分校验和",[31,485,486,489],{},[112,487,488],{},"git show \u003Ctagname>","查看标签信息与对应的提交信息",[31,491,492,495,496,499],{},[112,493,494],{},"git push \u003Cremote> \u003Ctagname>","推送标签，或",[112,497,498],{},"git push \u003Cremote> --tags","推送所有标签",[31,501,502,505,506,135,509,512],{},[112,503,504],{},"git tage -d \u003Ctagname>","删除标签，同时",[112,507,508],{},"git push \u003Cremote>:refs\u002Ftags\u002F\u003Ctagname>",[112,510,511],{},"git push \u003Cremote> --delete \u003Ctagname>","删除远程仓库的标签",[31,514,515,518],{},[112,516,517],{},"git checkout \u003Ctagname>","检出标签",[87,520,53],{"id":53},[13,522,523],{},[176,524,525],{},"敬请期待",[24,527,529],{"id":528},"git分支","Git分支",[28,531,532,567,581],{},[31,533,534,537,538],{},[112,535,536],{},"git branch","列出分支\n",[28,539,540,545,551,557],{},[31,541,542,544],{},[112,543,387],{},"查看每个分支的最后一次提交",[31,546,547,550],{},[112,548,549],{},"\u003Cbranch>","创建分支",[31,552,553,556],{},[112,554,555],{},"-d \u003Cbranch>","删除分支",[31,558,559,562,563,566],{},[112,560,561],{},"--merged","和",[112,564,565],{},"--no-merged","已经与当前分支合并和未合并的分支",[31,568,569,572,573],{},[112,570,571],{},"git checkout \u003Cbranch>","分支切换\n",[28,574,575],{},[31,576,577,580],{},[112,578,579],{},"git checkout -b \u003Cbranch>","创建并切换分支",[31,582,583,586,587],{},[112,584,585],{},"git merge \u003Cbranch>","合并分支\n",[28,588,589,595],{},[31,590,591,592],{},"顺着分支能到达另一分支时，只会简单的指针前进（右移），合并操作并无分歧，叫做",[112,593,594],{},"fast-forward",[31,596,597,598,601],{},"两分支岔开（diverged），会与两分支的共同祖先三方合并，创建一个新的提交。而遇到",[94,599,600],{},"冲突","，即两个分支对同一文件进行修改，会进行合并但没创建提交，需修改后自行提交",[87,603,64],{"id":64},[13,605,606,607,610,611,135,614],{},"远程跟踪分支",[94,608,609],{},"检出","本地分支会自动创建\"跟踪分支\"（所跟踪的分支称为上游分支），使用\n",[112,612,613],{},"git checkout -b \u003Cbranch> \u003Cremote>\u002F\u003Cbranch>",[112,615,616],{},"git checkout --track \u003Cremote>\u002F\u003Cbranch>",[13,618,619,620,623,624,627,628],{},"而",[94,621,622],{},"已有的","本地分支需要跟踪或者修改上游分支则可以使用：\n",[112,625,626],{},"git branch -u \u003Cremote>\u002F\u003Cbranch>","或着",[112,629,630],{},"--set-upstream-to",[13,632,633,634,135,637,640,641,644,645,648,649,652],{},"同时可以使用",[112,635,636],{},"@{u}",[112,638,639],{},"@{upstream}","代表上游分支，如",[112,642,643],{},"git merge @{u}","代替",[112,646,647],{},"git merge origin\u002Fmain","\n可使用",[112,650,651],{},"git branch -vv","来查看本地与上游分支的更多信息",[13,654,655,656],{},"删除远程分支",[112,657,658],{},"git push \u003Cremote> --delete \u003Cbranch>",[87,660,661],{"id":661},"变基",[13,663,664,667],{},[112,665,666],{},"git rebase \u003Cbranch>","\n待续。。。",[669,670],"hr",{},[24,672,674],{"id":673},"git内部原理","Git内部原理",[13,676,677,680,683,684,687,688,687,691,694,695,26],{},[176,678,679],{},"太无聊了",[112,681,682],{},".git","中重要文件：",[112,685,686],{},"HEAD","文件、",[112,689,690],{},"index",[112,692,693],{},"objects","目录、",[112,696,697],{},"refs",[87,699,700],{"id":700},"objects目录",[13,702,703,704,707],{},"保存所有数据，以Key-Value存储。通过",[112,705,706],{},"git hash-object","演示存储效果：",[208,709,712],{"className":710,"code":711,"language":213},[211],"$ echo \"hello\" | git hash-object -w --stdin\nce013625030ba8dba906f756967f9e9ca394464a\n",[112,713,711],{"__ignoreMap":216},[13,715,716,719,720,723,724,727,728,731],{},[112,717,718],{},"-w","写入数据库，",[112,721,722],{},"--stdin","从标准输入读取，或直接",[112,725,726],{},"git hash-object -w \u003Cfile>","。通过",[112,729,730],{},"git cat-file","读取数据：",[208,733,736],{"className":734,"code":735,"language":213},[211],"$ git cat-file -p ce013625030ba8dba906f756967f9e9ca394464a\nhello\n",[112,737,735],{"__ignoreMap":216},[13,739,740,741,744],{},"只保存了文件内容没有文件名等信息，该类型对象称为数据对象（blob object）。通过",[112,742,743],{},"-t","读取数据类型",[208,746,749],{"className":747,"code":748,"language":213},[211],"$ git cat-file -t ce013625030ba8dba906f756967f9e9ca394464a\nblob\n",[112,750,748],{"__ignoreMap":216},[752,753,754],"h4",{"id":754},"树对象",[13,756,757],{},"一个树对象有一条或多条树对象记录（tree entry），每条记录指向：文件模式、类型、数据对象或者子树对象的指针、文件名信息。",[208,759,762],{"className":760,"code":761,"language":213},[211],"$ git cat-file -p main^{tree}\n100644 blob 45f16d261584a37f3c3f3f631c7c08d0958baa2a    init.lua\n100644 blob 7bf88613cead41206b364137ca310a829645f228    lazy-lock.json\n040000 tree aff0b5e3d38b57a379d538056f60fa6f7a386fd0    lua\n",[112,763,761],{"__ignoreMap":216},[752,765,766],{"id":766},"提交对象",[13,768,769],{},"包含树对象的SHA-1值、父提交对象、作者信息以及提交注释",[752,771,772],{"id":772},"对象存储",[13,774,775,776,779,780,783,784],{},"假设数据为",[112,777,778],{},"content = \"hello\"","，令",[112,781,782],{},"header = \"blob #{content.length}\\0\"","，\n头部信息为对象类型 + 空格 + 数据的字节数 + 空字节。即",[112,785,786],{},"blob 5\\u0000",[13,788,619,789,792,793,796,797,800],{},[112,790,791],{},"store = heander + content","，Git会对",[112,794,795],{},"store","计算SHA-1校验和（作为Key）。\n由zlib压缩后即为对象的内容（Value）数据对象的",[112,798,799],{},"content","无限制但树对象与提交对象的内容固定",[87,802,78],{"id":78},[13,804,805,808],{},[112,806,807],{},".git\u002Frefs","目录下的含有SHA-1值的文件",[28,810,811,816],{},[31,812,813],{},[112,814,815],{},"echo 1a410efbd13591db07496601ebc7a059dd55cfe9 > .git\u002Frefs\u002Fheads\u002Fmaster",[31,817,818,821],{},[112,819,820],{},"git update-ref refs\u002Fheads\u002Fmaster 1a410efbd13591db07496601ebc7a059dd55cfe9","，git提供的方法更安全",[10,823,824],{},[13,825,826],{},"Git分支的本质就是一个指向某一系列提交之首的指针或引用",[752,828,830],{"id":829},"head引用","HEAD引用",[13,832,833,834,837],{},"运行",[112,835,836],{},"git branch \u003Cbranch>","时，通过HEAD文件获取最新提交的SHA-1值",[10,839,840],{},[13,841,842],{},"HEAD文件通常是一个符号引用，即指向其他引用的指针",[752,844,845],{"id":845},"标签引用",[13,847,848],{},"除三种主要对象类型外，还有标签对象。",[13,850,851],{},"而标签就是一个引用",[28,853,854,863],{},[31,855,856,857],{},"轻量标签：",[208,858,861],{"className":859,"code":860,"language":213},[211],"$ git update-ref refs\u002Ftags\u002Fv1.0 cac0cab538b970a37ea1e769cbbde608743bc96d\n",[112,862,860],{"__ignoreMap":216},[31,864,865,866,872,874,875,877,878,881,882,888],{},"附注标签：",[208,867,870],{"className":868,"code":869,"language":213},[211],"$ git tag -a v1.1 1a410efbd13591db07496601ebc7a059dd55cfe9 -m 'test tag'\n$ cat .git\u002Frefs\u002Ftags\u002Fv1.1\n9585191f37f7b0fb9444f35a9bf50de191beadc2\n",[112,871,869],{"__ignoreMap":216},[181,873],{},"先创建标签对象再通过",[94,876,78],{},"指向标签对象，通过",[112,879,880],{},"git cat-file -p","得到：",[208,883,886],{"className":884,"code":885,"language":213},[211],"$ git cat-file -p 9585191f37f7b0fb9444f35a9bf50de191beadc2\nobject 1a410efbd13591db07496601ebc7a059dd55cfe9\ntype commit\ntag v1.1\ntagger Scott Chacon \u003Cschacon@gmail.com> Sat May 23 16:48:58 2009 -0700\n\ntest tag\n",[112,887,885],{"__ignoreMap":216},[10,889,890],{},[13,891,892],{},"标签对象并不一定需要指向提交对象，也可以为数据对象或树对象打标签",[752,894,895],{"id":895},"远程引用",[13,897,898,899,902,903,905],{},"保存在",[112,900,901],{},"refs\u002Fremotes","下。当添加了远程仓库并进行推送，Git会记录最近一次推送的每一个分支对应的值，并保存在",[112,904,901],{},"目录下：",[208,907,910],{"className":908,"code":909,"language":213},[211],"$ git remote add origin git@github.com:schacon\u002Fsimplegit-progit.git\n$ git push origin master\nCounting objects: 11, done.\nCompressing objects: 100% (5\u002F5), done.\nWriting objects: 100% (7\u002F7), 716 bytes, done.\nTotal 7 (delta 2), reused 4 (delta 1)\nTo git@github.com:schacon\u002Fsimplegit-progit.git\n   a11bef0..ca82a6d  master -> master\n",[112,911,909],{"__ignoreMap":216},[13,913,914,915,918],{},"而查看",[112,916,917],{},"refs\u002Fremotes\u002Forigin\u002Fmaster","文件",[208,920,923],{"className":921,"code":922,"language":213},[211],"$ cat .git\u002Frefs\u002Fremotes\u002Forigin\u002Fmaster\nca82a6dff817ec66f44342007202690a93763949\n",[112,924,922],{"__ignoreMap":216},[13,926,927,928,931],{},"即为",[112,929,930],{},"origin\u002Fmaster","分支的SHA-1值",[669,933],{},[10,935,936],{},[13,937,938,939,944],{},"学习",[17,940,943],{"href":941,"rel":942},"https:\u002F\u002Flearngitbranching.js.org\u002F?locale=zh_CN",[21],"Learn Git Branching","记录",[87,946,947],{"id":947},"相对引用",[28,949,950,975],{},[31,951,952,955,956,959,960,962,963],{},[112,953,954],{},"^","，例如",[112,957,958],{},"HEAD^","表示",[112,961,686],{},"的上一次提交\n",[28,964,965],{},[31,966,967,970,971,974],{},[112,968,969],{},"^{num}","，一个提交可能有多个父节点，",[112,972,973],{},"num","表示选择第几个父节点",[31,976,977,955,980,959,983,986],{},[112,978,979],{},"~{num}",[112,981,982],{},"main~3",[112,984,985],{},"main","的上三次提交",[87,988,989],{"id":989},"扩展",[28,991,992,1005],{},[31,993,994,997,998,1001,1002,1004],{},[112,995,996],{},"git branch -f \u003Cbranch> \u003Ccommit>","将",[112,999,1000],{},"branch","分支指向",[112,1003,479],{},"提交",[31,1006,1007,1010,1011],{},[112,1008,1009],{},"git switch -c \u003Cbranch>","等同于",[112,1012,579],{},[752,1014,1015],{"id":1015},"撤销变更",[28,1017,1018,1027],{},[31,1019,1020,1023,1024,1026],{},[112,1021,1022],{},"git reset \u003Ccommit>","将当前分支回退到",[112,1025,479],{},"提交上",[31,1028,1029,1032,1033,1035],{},[112,1030,1031],{},"git revert \u003Ccommit>","反做",[112,1034,479],{},"的操作后添加提交",[13,1037,1038],{},"待续。。。",{"title":216,"searchDepth":1040,"depth":1040,"links":1041},2,[1042,1043,1052,1056],{"id":26,"depth":1040,"text":26},{"id":84,"depth":1040,"text":85,"children":1044},[1045,1047,1048,1049,1050,1051],{"id":89,"depth":1046,"text":89},3,{"id":219,"depth":1046,"text":219},{"id":338,"depth":1046,"text":338},{"id":372,"depth":1046,"text":372},{"id":441,"depth":1046,"text":441},{"id":53,"depth":1046,"text":53},{"id":528,"depth":1040,"text":529,"children":1053},[1054,1055],{"id":64,"depth":1046,"text":64},{"id":661,"depth":1046,"text":661},{"id":673,"depth":1040,"text":674,"children":1057},[1058,1059,1060,1061],{"id":700,"depth":1046,"text":700},{"id":78,"depth":1046,"text":78},{"id":947,"depth":1046,"text":947},{"id":989,"depth":1046,"text":989},"2023-02-03","笔记","md",{},true,"\u002Fblog\u002Fgit-learning",{"title":5,"description":1063},"blog\u002Fgit-learning",[1071],"Git","0gEKzIYfF4AqZEfCQca6YxoImzKMbBu9INPxYIxGNmc",{"id":1074,"title":1075,"avatar":1076,"body":1077,"description":1081,"extension":1064,"meta":1082,"name":1084,"navigation":1066,"path":1085,"seo":1086,"social":1087,"stem":1093,"__hash__":1094},"home\u002Fhome.md","Home","https:\u002F\u002Fstarrobe-blog.oss-cn-beijing.aliyuncs.com\u002Favatar\u002Fjashinchan.jpg",{"type":7,"value":1078,"toc":1079},[],{"title":216,"searchDepth":1040,"depth":1040,"links":1080},[],"Programming enthusiast, maybe.",{"layout":1083},"page","阿东","\u002Fhome",{"title":1075,"description":1081},{"github":1088,"email":1089,"bilibili":1090,"qq":1091,"rss":1092},"https:\u002F\u002Fgithub.com\u002Fstarrobe","mailto:starrobe@163.com","https:\u002F\u002Fspace.bilibili.com\u002F382631863","tencent:\u002F\u002Fmessage\u002F?uin=2604335528","\u002Ffeed.xml","home","XHOrpn2fXb8x87SMsqZTGaANCESyH9qV8TDm8rnQewI",1777128585938]