1466 lines
285 KiB
HTML
1466 lines
285 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="zh-CN">
|
||
<head>
|
||
<meta charset="UTF-8">
|
||
<meta name="renderer" content="webkit">
|
||
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"/>
|
||
<meta name="description" content="git:是目前世界上最先进的分布式版本控制系统 - 最专业的Linux命令大全,内容包含Linux命令手册、详解、学习,值得收藏的Linux命令速查手册。">
|
||
<meta name="keywords" content="Linux,Command,命令大全,Linux命令手册,git,是目前世界上最先进的分布式版本控制系统">
|
||
<title>git 命令,Linux git 命令详解:是目前世界上最先进的分布式版本控制系统 - Linux 命令搜索引擎</title>
|
||
<link rel="shortcut icon" href="../img/favicon.ico">
|
||
<link rel="stylesheet" type="text/css" href="../css/index.css?v=1747070672619">
|
||
<script src="../js/dark-mode.min.js"></script>
|
||
<script type="module" src="../js/github-corners.js"></script>
|
||
</head>
|
||
<body>
|
||
<dark-mode permanent dark="Dark" light="Light" style="position: fixed;left: 10px;top: 8px; z-index: 999;"></dark-mode>
|
||
<github-corners target="__blank" z-index="999" position="fixed" href="https://github.com/jaywcjlove/linux-command"></github-corners>
|
||
<div class="header header_list">
|
||
<div class="header_inner">
|
||
<div class="logo">
|
||
<a href="/">
|
||
<svg width="183px" height="48px" viewBox="0 0 183 48" version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"> <!-- kenny wang <wowohoo@qq.com> https://github.com/jaywcjlove --> <title>logo</title> <desc>Linux Command Logo. https://github.com/jaywcjlove</desc><g stroke="none" stroke-width="1" fill="none" fill-rule="evenodd"> <g transform="translate(-576.000000, -261.000000)" fill="currentColor"> <g id="logo" transform="translate(576.000000, 261.000000)"> <path d="M20.4917792,0.000336524232 C20.1886146,-0.000100520225 19.8723998,0.0124863601 19.542641,0.0387964365 C11.2083649,0.710004944 13.4186692,9.51473754 13.2949769,12.4631618 C13.1427718,14.6193207 12.7056049,16.3185233 11.2226825,18.426428 C9.48047033,20.4982285 7.02763261,23.8514609 5.86566251,27.3420607 C5.3172635,28.9894735 5.05630425,30.6686289 5.29730805,32.2578406 C5.22181299,32.325447 5.14994103,32.3962788 5.08160039,32.469239 C4.57008792,33.0153217 4.19213625,33.6769851 3.77100458,34.1224689 C3.37755968,34.5149436 2.81698897,34.6642292 2.20097918,34.8852382 C1.58472464,35.1063477 0.908127379,35.4323261 0.497432332,36.2204265 C0.497432332,36.2204265 0.497432332,36.2207368 0.49712203,36.2207368 C0.496684986,36.222048 0.495373852,36.2233591 0.494936808,36.2246702 L0.494936808,36.2246702 C0.123151829,36.919077 0.233680372,37.718746 0.347224522,38.4596325 C0.460773043,39.2004972 0.575720105,39.9005856 0.423139144,40.3755699 C-0.0645762474,41.7086473 -0.126850712,42.6307542 0.216491414,43.2996202 C0.560563403,43.9698759 1.2680029,44.2657113 2.06756262,44.432706 C3.66668644,44.7666954 5.83232039,44.6837094 7.53908826,45.5883128 L7.68579097,45.3115063 L7.54060917,45.5891344 C9.36778716,46.5444437 11.2201913,46.8837519 12.698079,46.5461831 C13.7695766,46.3014513 14.6393781,45.6634363 15.0860725,44.6816946 C16.2420201,44.6760567 17.5104717,44.1864315 19.5423657,44.0745568 C20.9208039,43.9635213 22.6427241,44.564051 24.6233484,44.4540775 C24.6751207,44.6689591 24.750052,44.8756375 24.8526175,45.0720452 C24.8539287,45.0742305 24.8548028,45.0759786 24.8556769,45.0780328 C25.6234722,46.6133699 27.0500902,47.3156173 28.570428,47.1956355 C30.0927718,47.075492 31.711331,46.1778551 33.0196848,44.6208231 L32.7798304,44.4192582 L33.0215204,44.618616 C34.2685787,43.1065034 36.3384911,42.4794975 37.7110118,41.6516741 C38.3972721,41.2377581 38.9541192,40.7194802 38.9971462,39.966706 C39.0401514,39.2142991 38.5984218,38.3711223 37.5826868,37.2436088 L37.5823765,37.2432985 C37.5820662,37.2428614 37.5815024,37.2424244 37.5810654,37.2415503 C37.2473295,36.8644028 37.0881185,36.1654026 36.91702,35.4210285 C36.7460395,34.6771089 36.5551865,33.8746254 35.9444344,33.3545687 L35.9444344,33.3545687 C35.9431233,33.3532575 35.9418121,33.3523835 35.940938,33.3515094 L35.940938,33.3515094 C35.6978714,33.1397045 35.4452772,32.9959518 35.1909042,32.8993694 C36.0400422,30.3810493 35.7068789,27.8734149 34.8497254,25.6073831 C33.7977638,22.8263338 31.9611937,20.4030752 30.5585738,18.7453569 C28.9885703,16.7650385 27.4529665,14.8848863 27.4832187,12.1079627 C27.5299825,7.86977213 27.9494053,0.0101787654 20.4914689,0 L20.4917792,0.000336524232 Z M21.5014393,6.5296802 C21.9246338,6.5296802 22.2860696,6.65372652 22.6573476,6.92320377 C23.0345213,7.1969553 23.3062494,7.53965497 23.5252523,8.01821865 C23.7401952,8.48461502 23.843613,8.94086321 23.8537568,9.48229573 C23.8537568,9.49649968 23.8537568,9.50864951 23.8576902,9.52285346 C23.8616236,10.0784681 23.7664397,10.5509481 23.5555483,11.0335676 C23.4352081,11.3089536 23.2970146,11.540089 23.1316064,11.7401941 C23.0754506,11.7132285 23.0171357,11.6873118 22.9566488,11.6624396 L22.9566488,11.6624396 C22.5373789,11.4828667 22.2157491,11.3685884 21.9476879,11.2755722 C22.044856,11.158772 22.1257661,11.0202464 22.1969169,10.8470719 C22.3043949,10.5854877 22.3571155,10.3299784 22.367255,10.025813 C22.367255,10.0136631 22.3711884,10.00348 22.3711884,9.98931975 C22.3772633,9.69732161 22.3387597,9.44789596 22.2535753,9.19239103 C22.1643483,8.92472316 22.0507955,8.73208707 21.886541,8.57188842 C21.722291,8.41168541 21.5580366,8.33869024 21.361336,8.33260221 C21.3521143,8.33216517 21.3429364,8.33216517 21.3338459,8.33216517 C21.1488275,8.33260221 20.9881699,8.39616596 20.8219532,8.53532529 C20.6475593,8.6813331 20.5177834,8.86788115 20.4103054,9.12744186 C20.3028318,9.38699819 20.2501067,9.64452664 20.239976,9.95073309 C20.2377908,9.96288293 20.2377908,9.97306607 20.2377908,9.9852159 C20.2342945,10.1535261 20.2449584,10.307711 20.2709188,10.4574381 C19.8923378,10.2687966 19.535574,10.1401875 19.2007499,10.0604924 C19.181651,9.91570835 19.1706375,9.76629596 19.1670975,9.61007442 L19.1670975,9.56750629 C19.1610225,9.01391519 19.2522643,8.53941165 19.4651836,8.05679657 C19.6781029,7.57417712 19.9417194,7.2274173 20.3128051,6.94555422 C20.6838952,6.66369114 21.0488973,6.53391079 21.4808239,6.52985938 L21.5010154,6.52985938 L21.5014393,6.5296802 Z M15.7091362,6.98827969 C15.9898804,6.98871673 16.2410892,7.0827381 16.5009296,7.29023807 C16.7828014,7.51531597 16.9957164,7.80326271 17.1741616,8.20882685 C17.3526112,8.614391 17.4479175,9.01995077 17.4742757,9.49851445 L17.4742757,9.50244785 C17.4870374,9.70344023 17.485464,9.89263677 17.469643,10.0758677 C17.4141165,10.091645 17.3597045,10.1087334 17.3064069,10.1270762 C17.0036968,10.2312719 16.7369205,10.373272 16.5044085,10.5268101 C16.5271785,10.366205 16.5305437,10.2032486 16.5131057,10.0215605 C16.5109204,10.0114211 16.5109204,10.0032921 16.5109204,9.99319633 C16.4865771,9.75189098 16.435893,9.54911109 16.3507218,9.34429895 C16.2594713,9.131384 16.1580813,8.98132478 16.0242452,8.86573527 C15.9029566,8.76098882 15.7883592,8.71289208 15.6622806,8.71384046 C15.6492567,8.71384046 15.636058,8.71427751 15.6227281,8.71558864 C15.4807804,8.72773848 15.3631674,8.79669098 15.251638,8.93255936 C15.1401086,9.068419 15.0671091,9.23672919 15.0143884,9.4597792 C14.9616634,9.68284232 14.9474682,9.90184967 14.9697706,10.1532945 C14.9697706,10.1634339 14.9719558,10.1715629 14.9719558,10.1816586 C14.9962992,10.4249963 15.0449553,10.6277718 15.1321501,10.8325883 C15.2213771,11.0434797 15.3247905,11.1935346 15.4586266,11.3091153 C15.481047,11.3284764 15.5032139,11.3458708 15.525289,11.361399 C15.3860816,11.468536 15.3196072,11.5179308 15.2055298,11.6017559 C15.1323642,11.6554425 15.0452263,11.7193646 14.94395,11.7940162 C14.7230765,11.5871106 14.5507673,11.3270648 14.4001137,10.984671 C14.2216641,10.5791112 14.1263578,10.1735471 14.0979674,9.69498342 L14.0979674,9.69105002 C14.0716136,9.21249508 14.1182463,8.8008429 14.2500545,8.37500864 C14.3818627,7.94916563 14.5582845,7.6409444 14.813785,7.38745861 C15.06929,7.13399031 15.3268184,7.00623784 15.6370763,6.99001912 C15.6613322,6.98870799 15.6853347,6.98827095 15.709123,6.98827095 L15.7091362,6.98827969 Z M18.3434478,10.3083666 C18.9959552,10.3057443 19.7811624,10.5197693 20.731756,11.1309629 C21.3156605,11.5106715 21.7700031,11.5424053 22.8162176,11.9904939 L22.8175288,11.9909309 L22.8188399,11.991368 C23.322219,12.1979021 23.6176741,12.4671083 23.7620255,12.7505841 C23.906377,13.034073 23.9099039,13.3414857 23.7890786,13.6648724 C23.5474411,14.3116676 22.7761407,14.9923468 21.6937826,15.3303395 L21.6929085,15.3307766 L21.6920344,15.3312136 C21.1642857,15.5026793 20.7040867,15.8813302 20.1615484,16.1915706 C19.6190277,16.5017979 19.00512,16.7520102 18.1703739,16.7037212 C18.1703739,16.7037168 18.1703739,16.7037212 18.1703739,16.7037212 C17.4597396,16.6622893 17.0349499,16.4210539 16.650849,16.1123607 C16.2667437,15.8036631 15.9320245,15.4158517 15.4418966,15.1280491 L15.4405854,15.1271751 L15.4392743,15.126301 C14.6497885,14.6800742 14.2187709,14.163964 14.0834969,13.7165354 C13.9482185,13.2691068 14.075193,12.8871911 14.4668766,12.5936327 C14.9072645,12.2635986 15.2131825,12.0390976 15.4169632,11.8895453 C15.6194022,11.7409983 15.703625,11.685297 15.7680935,11.623394 C15.7684038,11.622957 15.7685305,11.622957 15.7689675,11.6225199 L15.7692735,11.6220829 C16.1001729,11.3088706 16.6276463,10.738226 17.4227569,10.4645313 C17.696421,10.3703264 18.001784,10.3095466 18.3435746,10.3081961 L18.3434478,10.3083666 Z M22.9062619,13.0069369 C22.6246829,13.0237631 22.3297828,13.1687002 21.9864013,13.3604054 C21.6430199,13.5521105 21.256878,13.7973406 20.8384079,14.0388338 C20.0014721,14.5218204 19.038047,14.9837283 18.0805918,14.9837283 C17.1216551,14.9837283 16.3555118,14.5408493 15.7808726,14.0854752 C15.4935509,13.8577838 15.2564149,13.6284404 15.0669561,13.4510265 C14.9722311,13.3623109 14.8900799,13.2867065 14.8134179,13.2276487 C14.7367734,13.1685909 14.6743853,13.1100357 14.5461303,13.1100357 L14.5400116,13.3795435 C14.5308337,13.4697233 14.5213935,13.4669437 14.5251084,13.4693999 C14.5310959,13.4733333 14.5608587,13.4835601 14.5955731,13.5103509 C14.6519344,13.5537495 14.7301609,13.6245375 14.8230067,13.7114832 C15.0086981,13.8853788 15.2554403,14.124464 15.5592255,14.3652012 C16.166796,14.8466668 17.0117515,15.3406363 18.0806093,15.3406363 C19.1509618,15.3406363 20.1636375,14.8403471 21.016875,14.3479598 C21.4434872,14.1017639 21.8309534,13.8560094 22.1604324,13.6720705 C22.4898897,13.4881185 22.7670895,13.3727781 22.9275766,13.3632068 L22.9062925,13.00695 L22.9062619,13.0069369 Z M23.8576858,14.2878093 C24.5685911,17.0901733 26.2220701,21.1378562 27.2848005,23.113201 C27.8496849,24.1612205 28.9735097,26.3878921 29.4590574,29.0706371 C29.7667148,29.0611969 30.1054855,29.1059065 30.4682673,29.1987042 C31.7377591,25.907589 29.3917525,22.3626165 28.3189832,21.375368 C27.8858722,20.9551061 27.8650557,20.7668098 28.0797669,20.7757081 C29.2436775,21.8049915 30.7716374,23.8752142 31.3275492,26.211938 C31.581035,27.2774436 31.6350799,28.3975886 31.3630809,29.5030663 C31.4961478,29.5583437 31.6312951,29.6184504 31.7682604,29.683286 C33.806037,30.6755779 34.5596721,31.5384567 34.1973186,32.716121 C34.0779748,32.7117506 33.960576,32.7126247 33.8460659,32.7152469 C33.8354021,32.7155572 33.8247819,32.715684 33.814118,32.716121 C34.1092104,31.7826203 33.4554837,31.0941179 31.7135031,30.305952 C29.9067264,29.5110511 28.4669839,29.5901387 28.2236507,31.2022427 C28.2080919,31.2867016 28.1955487,31.3727644 28.1860212,31.460029 C28.05104,31.506902 27.9153158,31.5667509 27.7792552,31.6412014 C26.9308557,32.1054213 26.4677896,32.9477371 26.2102393,33.9808403 C25.9529032,35.0131131 25.8791213,36.2610673 25.8081016,37.6639101 L25.8081016,37.6647842 C25.7647031,38.3701826 25.4746935,39.3242507 25.1805582,40.3347805 C22.2207839,42.446033 18.1128938,43.3607409 14.6251435,40.9805006 C14.3887768,40.6065916 14.1176344,40.2361221 13.8385378,39.8707355 C13.6603154,39.6373843 13.4772332,39.4054841 13.2952172,39.1768225 C13.6532528,39.1768225 13.9575843,39.1184771 14.2035442,39.0069433 C14.5094142,38.8682516 14.724322,38.6454901 14.8306462,38.3594969 C15.0432858,37.7875325 14.8297721,36.9806654 14.1489836,36.0592664 C13.4682956,35.137933 12.3154554,34.0981212 10.6214273,33.0592009 C10.6214273,33.0592009 10.621117,33.0592009 10.621117,33.0588906 C9.37658486,32.2846183 8.68057408,31.3355981 8.3547924,30.3051959 C8.02898013,29.2747018 8.07466439,28.1604089 8.32577265,27.0602631 C8.80774091,24.9485692 10.0461107,22.8947793 10.8362565,21.605909 C11.0489879,21.4493815 10.9122629,21.8964561 10.0363515,23.5230089 C9.25134103,25.0101357 7.78376323,28.4420972 9.79314068,31.1210705 C9.84684033,29.2145776 10.3021401,27.2701931 11.0664741,25.45145 C12.1797968,22.9278068 14.5084483,18.5514927 14.6933968,15.0635108 C14.7887555,15.1327561 15.1164383,15.3538525 15.2624505,15.4368866 C15.2627608,15.4373237 15.2628875,15.4373237 15.2633246,15.4373237 C15.6905181,15.6888908 16.0113611,16.0566244 16.426903,16.3905832 C16.8432709,16.7252019 17.3634237,17.0142238 18.149269,17.0600129 L18.149269,17.0600129 C19.066516,17.113092 19.7655905,16.8289912 20.3383504,16.5014745 C20.9102449,16.1744603 21.3671137,15.8125482 21.7999582,15.6712779 C21.8003952,15.6708409 21.8012693,15.6708409 21.8017063,15.6708409 C22.7163355,15.3848215 23.44356,14.8785842 23.857393,14.2881327 L23.8576858,14.2878093 Z M29.6669682,30.3312962 C30.0374289,30.329548 30.4861993,30.4530917 30.9774372,30.6728508 C32.2995623,31.2832227 32.713238,31.8063999 32.3522873,32.5749338 C32.0481219,33.1548918 30.7462669,34.0775407 29.8540319,33.8342075 C28.9435503,33.5989814 28.4994564,32.2869871 28.6474877,31.2953987 C28.7267763,30.6220356 29.1076387,30.3339097 29.6669682,30.3312962 L29.6669682,30.3312962 Z M28.1710786,32.1433306 C28.2458176,33.3559191 28.8457529,34.5926195 29.9067526,34.8602742 C31.0678224,35.1661922 32.7418469,34.16998 33.4486352,33.3574182 C33.5895689,33.3517803 33.7273516,33.3448313 33.8611658,33.3416409 C34.4811527,33.3266503 35.001157,33.3620509 35.5324588,33.8267253 L35.534207,33.8284735 L35.5359552,33.8302216 C35.9442465,34.1761336 36.1383204,34.8298385 36.3066481,35.5621545 C36.4749627,36.294475 36.6095636,37.0920505 37.11435,37.6602345 L37.115224,37.6611086 L37.1156611,37.6619827 C38.0861227,38.7388952 38.3980544,39.4668146 38.3715083,39.931406 C38.344936,40.3960279 38.008556,40.7409347 37.3873891,41.1155867 C36.1455928,41.864576 33.9453056,42.5158727 32.5399192,44.2181871 C31.3196037,45.6704378 29.8315635,46.4680352 28.5210638,46.5714617 C27.2105642,46.6748883 26.0799127,46.1309646 25.4133237,44.793071 L25.4115756,44.7900117 L25.4098274,44.7869524 C24.9962959,44.0002986 25.1685614,42.758852 25.5169207,41.4493706 C25.8652845,40.1398937 26.3657922,38.7953264 26.4327911,37.7024923 L26.4327911,37.7007442 L26.4327911,37.698996 C26.5036666,36.2987755 26.5820418,35.0759688 26.8172504,34.1324728 C27.0524633,33.1889769 27.4228236,32.5499829 28.0790545,32.1909116 C28.109604,32.1742165 28.139948,32.1584392 28.1701128,32.1435097 L28.1710786,32.1433306 Z M6.86074718,32.2348346 C6.95869322,32.2351449 7.06234705,32.2434006 7.17277507,32.2601394 C7.91559769,32.3726653 8.5633675,32.8920358 9.18746261,33.7385341 C9.8115621,34.5850455 10.3922762,35.7405823 10.9892352,37.0223812 L10.9901093,37.0241294 L10.9905463,37.0258776 C11.4702594,38.0271115 12.4825418,39.128044 13.3403902,40.2511564 C14.1982341,41.3742689 14.8621527,42.5016163 14.7756966,43.3644732 L14.7753863,43.3684066 L14.775076,43.37234 C14.6632363,44.843978 13.8330966,45.6451198 12.5587449,45.9361914 C11.2847734,46.2271625 9.55771794,45.9379396 7.83269472,45.035587 L7.83094655,45.035587 C5.9224477,44.0247687 3.65205856,44.1251622 2.19566909,43.8209924 C1.46727769,43.6688572 0.99200058,43.44013 0.773862951,43.0151698 C0.55571221,42.5902315 0.550839164,41.8488511 1.01440785,40.5847437 L1.01659307,40.5791059 L1.01834125,40.573468 C1.24759292,39.8663213 1.07793226,39.0925822 0.96663015,38.3663367 C0.855328038,37.6400911 0.800894151,36.9795116 1.04888192,36.5190765 L1.05019305,36.5168913 L1.05150418,36.514706 C1.36900824,35.9026821 1.83472718,35.683902 2.41273159,35.4765375 C2.990736,35.2691556 3.67612223,35.1062953 4.21734934,34.5638925 L4.21997161,34.5612703 L4.22259387,34.558648 C4.72293985,34.0308163 5.09877623,33.3691834 5.53863963,32.8995879 C5.90977341,32.5033678 6.28118253,32.2407652 6.84099715,32.2368755 L6.86053303,32.2368755 L6.86074718,32.2348346 Z"></path> <path d="M58.5014648,40 L58.5014648,6.7578125 L65.4194336,6.7578125 L65.4194336,35.2832031 L80.4008789,35.2832031 L80.4008789,40 L58.5014648,40 L58.5014648,40 L58.5014648,40 Z M86.2524414,40 L86.2524414,15.3378906 L92.9008789,15.3378906 L92.9008789,40 L86.2524414,40 L86.2524414,40 L86.2524414,40 Z M86.2524414,11.1826172 L86.2524414,5.63476562 L92.9008789,5.63476562 L92.9008789,11.1826172 L86.2524414,11.1826172 L86.2524414,11.1826172 L86.2524414,11.1826172 Z M100.211426,40 L100.211426,15.3378906 L106.859863,15.3378906 L106.859863,19.9873047 C109.031098,16.513329 111.8312,14.7763672 115.260254,14.7763672 C117.461437,14.7763672 119.198399,15.4726493 120.471191,16.8652344 C121.743984,18.2578195 122.380371,20.1594932 122.380371,22.5703125 L122.380371,40 L115.731934,40 L115.731934,24.2099609 C115.731934,21.4098167 114.803557,20.0097656 112.946777,20.0097656 C110.835439,20.0097656 108.806488,21.4996596 106.859863,24.4794922 L106.859863,40 L100.211426,40 L100.211426,40 L100.211426,40 Z M145.672363,40 L145.672363,35.3505859 C143.516102,38.8245616 140.716,40.5615234 137.271973,40.5615234 C135.07079,40.5615234 133.333828,39.8652413 132.061035,38.4726562 C130.788242,37.0800712 130.151855,35.1783975 130.151855,32.7675781 L130.151855,15.3378906 L136.800293,15.3378906 L136.800293,31.1279297 C136.800293,33.9280739 137.736156,35.328125 139.60791,35.328125 C141.704275,35.328125 143.725739,33.838231 145.672363,30.8583984 L145.672363,15.3378906 L152.320801,15.3378906 L152.320801,40 L145.672363,40 L145.672363,40 L145.672363,40 Z M158.003418,40 L166.471191,27.6240234 L158.362793,15.3378906 L165.932129,15.3378906 L171.23291,23.1542969 L176.309082,15.3378906 L181.699707,15.3378906 L173.973145,27.4443359 L182.26123,40 L174.691895,40 L169.166504,31.8466797 L163.506348,40 L158.003418,40 L158.003418,40 L158.003418,40 Z"></path> </g> </g> </g> </svg>
|
||
</a>
|
||
</div>
|
||
<div class="search">
|
||
<ul class="search-list" id="result">
|
||
<!-- <li><a href="#"><strong>find</strong> - 指定目录下查找文件。</a></li> -->
|
||
</ul>
|
||
<input type="text" class="query" id="query" autocomplete="off" autofocus="autofocus" placeholder="Linux 命令搜索"/>
|
||
<div class="enter-input">
|
||
<input type="hidden" id="current_path" value="/c/git.html">
|
||
<button id="search_btn">搜索</button>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
<script type="text/javascript" src="../js/copy-to-clipboard.js"></script>
|
||
|
||
<div class="markdown-body">
|
||
|
||
<span class="edit_btn">
|
||
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/edit/master/command/git.md">纠正错误</a>
|
||
<span class="split"></span>
|
||
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/edit/master/command/git.md">添加实例</a>
|
||
</span>
|
||
|
||
|
||
<dark-mode style="position: fixed; top: 8px; left: 10px; z-index: 999;;display: none;" dark="Dark" light="Light"></dark-mode><script>const t=document;const e="_dark_mode_theme_";const s="permanent";const o="colorschemechange";const i="permanentcolorscheme";const h="light";const r="dark";const n=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){const t=this.getAttribute(e);return t===null?"":t},set(t){this.setAttribute(e,t)}})};const c=(t,e,s=e)=>{Object.defineProperty(t,s,{enumerable:true,get(){return this.hasAttribute(e)},set(t){if(t){this.setAttribute(e,"")}else{this.removeAttribute(e)}}})};class a extends HTMLElement{static get observedAttributes(){return["mode",h,r,s]}LOCAL_NANE=e;constructor(){super();this.t()}connectedCallback(){n(this,"mode");n(this,r);n(this,h);c(this,s);const a=localStorage.getItem(e);if(a&&[h,r].includes(a)){this.mode=a;this.permanent=true}if(this.permanent&&!a){localStorage.setItem(e,this.mode)}const l=[h,r].includes(a);if(this.permanent&&a){this.o()}else{if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches){this.mode=r;this.o()}if(window.matchMedia&&window.matchMedia("(prefers-color-scheme: light)").matches){this.mode=h;this.o()}}if(!this.permanent&&!l){window.matchMedia("(prefers-color-scheme: light)").onchange=t=>{this.mode=t.matches?h:r;this.o()};window.matchMedia("(prefers-color-scheme: dark)").onchange=t=>{this.mode=t.matches?r:h;this.o()}}const d=new MutationObserver(((s,h)=>{this.mode=t.documentElement.dataset.colorMode;if(this.permanent&&l){localStorage.setItem(e,this.mode);this.i(i,{permanent:this.permanent})}this.h();this.i(o,{colorScheme:this.mode})}));d.observe(t.documentElement,{attributes:true});this.i(o,{colorScheme:this.mode});this.h()}attributeChangedCallback(t,s,o){if(t==="mode"&&s!==o&&[h,r].includes(o)){const t=localStorage.getItem(e);if(this.mode===t){this.mode=o;this.h();this.o()}else if(this.mode&&this.mode!==t){this.h();this.o()}}else if((t===h||t===r)&&s!==o){this.h()}if(t==="permanent"&&typeof this.permanent==="boolean"){this.permanent?localStorage.setItem(e,this.mode):localStorage.removeItem(e)}}o(){t.documentElement.setAttribute("data-color-mode",this.mode)}h(){this.icon.textContent=this.mode===h?"🌒":"🌞";this.text.textContent=this.mode===h?this.getAttribute(r):this.getAttribute(h)}t(){var s=this.attachShadow({mode:"open"});this.label=t.createElement("span");this.label.setAttribute("class","wrapper");this.label.onclick=()=>{this.mode=this.mode===h?r:h;if(this.permanent){localStorage.setItem(e,this.mode)}this.o();this.h()};s.appendChild(this.label);this.icon=t.createElement("span");this.label.appendChild(this.icon);this.text=t.createElement("span");this.label.appendChild(this.text);const o=`
|
||
[data-color-mode*='dark'], [data-color-mode*='dark'] body {
|
||
color-scheme: dark;
|
||
--color-theme-bg: #0d1117;
|
||
--color-theme-text: #c9d1d9;
|
||
background-color: var(--color-theme-bg);
|
||
color: var(--color-theme-text);
|
||
}
|
||
|
||
[data-color-mode*='light'], [data-color-mode*='light'] body {
|
||
color-scheme: light;
|
||
--color-theme-bg: #fff;
|
||
--color-theme-text: #24292f;
|
||
background-color: var(--color-theme-bg);
|
||
color: var(--color-theme-text);
|
||
}`;const i="_dark_mode_style_";const n=t.getElementById(i);if(!n){var c=t.createElement("style");c.id=i;c.textContent=o;t.head.appendChild(c)}var a=t.createElement("style");a.textContent=`
|
||
.wrapper { cursor: pointer; user-select: none; position: relative; }
|
||
.wrapper > span + span { margin-left: .4rem; }
|
||
`;s.appendChild(a)}i(t,e){this.dispatchEvent(new CustomEvent(t,{bubbles:true,composed:true,detail:e}))}}customElements.define("dark-mode",a);</script><script>const __TEMPLATE__ = document.createElement('template');
|
||
__TEMPLATE__.innerHTML = `
|
||
<style>
|
||
|
||
markdown-style h1:hover a.anchor .octicon-link:before,
|
||
markdown-style h2:hover a.anchor .octicon-link:before,
|
||
markdown-style h3:hover a.anchor .octicon-link:before,
|
||
markdown-style h4:hover a.anchor .octicon-link:before,
|
||
markdown-style h5:hover a.anchor .octicon-link:before,
|
||
markdown-style h6:hover a.anchor .octicon-link:before {
|
||
width: 16px;
|
||
height: 16px;
|
||
content: ' ';
|
||
display: inline-block;
|
||
background-color: currentColor;
|
||
-webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
|
||
mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' version='1.1' aria-hidden='true'><path fill-rule='evenodd' d='M7.775 3.275a.75.75 0 001.06 1.06l1.25-1.25a2 2 0 112.83 2.83l-2.5 2.5a2 2 0 01-2.83 0 .75.75 0 00-1.06 1.06 3.5 3.5 0 004.95 0l2.5-2.5a3.5 3.5 0 00-4.95-4.95l-1.25 1.25zm-4.69 9.64a2 2 0 010-2.83l2.5-2.5a2 2 0 012.83 0 .75.75 0 001.06-1.06 3.5 3.5 0 00-4.95 0l-2.5 2.5a3.5 3.5 0 004.95 4.95l1.25-1.25a.75.75 0 00-1.06-1.06l-1.25 1.25a2 2 0 01-2.83 0z'></path></svg>");
|
||
}
|
||
[data-color-mode*='light'], [data-color-mode*='light'] body, markdown-style[theme*='light'] { --color-prettylights-syntax-comment: #6e7781; --color-prettylights-syntax-constant: #0550ae; --color-prettylights-syntax-entity: #8250df; --color-prettylights-syntax-storage-modifier-import: #24292f; --color-prettylights-syntax-entity-tag: #116329; --color-prettylights-syntax-keyword: #cf222e; --color-prettylights-syntax-string: #0a3069; --color-prettylights-syntax-variable: #953800; --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; --color-prettylights-syntax-invalid-illegal-text: #f6f8fa; --color-prettylights-syntax-invalid-illegal-bg: #82071e; --color-prettylights-syntax-carriage-return-text: #f6f8fa; --color-prettylights-syntax-carriage-return-bg: #cf222e; --color-prettylights-syntax-string-regexp: #116329; --color-prettylights-syntax-markup-list: #3b2300; --color-prettylights-syntax-markup-heading: #0550ae; --color-prettylights-syntax-markup-italic: #24292f; --color-prettylights-syntax-markup-bold: #24292f; --color-prettylights-syntax-markup-deleted-text: #82071e; --color-prettylights-syntax-markup-deleted-bg: #FFEBE9; --color-prettylights-syntax-markup-inserted-text: #116329; --color-prettylights-syntax-markup-inserted-bg: #dafbe1; --color-prettylights-syntax-markup-changed-text: #953800; --color-prettylights-syntax-markup-changed-bg: #ffd8b5; --color-prettylights-syntax-markup-ignored-text: #eaeef2; --color-prettylights-syntax-markup-ignored-bg: #0550ae; --color-prettylights-syntax-meta-diff-range: #8250df; --color-prettylights-syntax-brackethighlighter-angle: #57606a; --color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f; --color-prettylights-syntax-constant-other-reference-link: #0a3069; --color-fg-default: #24292f; --color-fg-muted: #57606a; --color-fg-subtle: #6e7781; --color-canvas-default: #ffffff; --color-canvas-subtle: #f6f8fa; --color-border-default: #d0d7de; --color-border-muted: hsla(210,18%,87%,1); --color-neutral-muted: rgba(175,184,193,0.2); --color-accent-fg: #0969da; --color-accent-emphasis: #0969da; --color-attention-subtle: #fff8c5; --color-danger-fg: #cf222e; } [data-color-mode*='dark'], [data-color-mode*='dark'] body, markdown-style[theme*='dark'] { --color-prettylights-syntax-comment: #8b949e; --color-prettylights-syntax-constant: #79c0ff; --color-prettylights-syntax-entity: #d2a8ff; --color-prettylights-syntax-storage-modifier-import: #c9d1d9; --color-prettylights-syntax-entity-tag: #7ee787; --color-prettylights-syntax-keyword: #ff7b72; --color-prettylights-syntax-string: #a5d6ff; --color-prettylights-syntax-variable: #ffa657; --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; --color-prettylights-syntax-invalid-illegal-text: #f0f6fc; --color-prettylights-syntax-invalid-illegal-bg: #8e1519; --color-prettylights-syntax-carriage-return-text: #f0f6fc; --color-prettylights-syntax-carriage-return-bg: #b62324; --color-prettylights-syntax-string-regexp: #7ee787; --color-prettylights-syntax-markup-list: #f2cc60; --color-prettylights-syntax-markup-heading: #1f6feb; --color-prettylights-syntax-markup-italic: #c9d1d9; --color-prettylights-syntax-markup-bold: #c9d1d9; --color-prettylights-syntax-markup-deleted-text: #ffdcd7; --color-prettylights-syntax-markup-deleted-bg: #67060c; --color-prettylights-syntax-markup-inserted-text: #aff5b4; --color-prettylights-syntax-markup-inserted-bg: #033a16; --color-prettylights-syntax-markup-changed-text: #ffdfb6; --color-prettylights-syntax-markup-changed-bg: #5a1e02; --color-prettylights-syntax-markup-ignored-text: #c9d1d9; --color-prettylights-syntax-markup-ignored-bg: #1158c7; --color-prettylights-syntax-meta-diff-range: #d2a8ff; --color-prettylights-syntax-brackethighlighter-angle: #8b949e; --color-prettylights-syntax-sublimelinter-gutter-mark: #484f58; --color-prettylights-syntax-constant-other-reference-link: #a5d6ff; --color-fg-default: #c9d1d9; --color-fg-muted: #8b949e; --color-fg-subtle: #484f58; --color-canvas-default: #0d1117; --color-canvas-subtle: #161b22; --color-border-default: #30363d; --color-border-muted: #21262d; --color-neutral-muted: rgba(110,118,129,0.4); --color-accent-fg: #58a6ff; --color-accent-emphasis: #1f6feb; --color-attention-subtle: rgba(187,128,9,0.15); --color-danger-fg: #f85149; } markdown-style { display: block; -webkit-text-size-adjust: 100%; font-family: -apple-system,BlinkMacSystemFont,"Segoe UI",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; font-size: 16px; line-height: 1.5; word-wrap: break-word; color: var(--color-fg-default); background-color: var(--color-canvas-default); } markdown-style details, markdown-style figcaption, markdown-style figure { display: block; } markdown-style summary { display: list-item; } markdown-style [hidden] { display: none !important; } markdown-style a { background-color: transparent; color: var(--color-accent-fg); text-decoration: none; } markdown-style a:active, markdown-style a:hover { outline-width: 0; } markdown-style abbr[title] { border-bottom: none; text-decoration: underline dotted; } markdown-style b, markdown-style strong { font-weight: 600; } markdown-style dfn { font-style: italic; } markdown-style h1 { margin: .67em 0; font-weight: 600; padding-bottom: .3em; font-size: 2em; border-bottom: 1px solid var(--color-border-muted); } markdown-style mark { background-color: var(--color-attention-subtle); color: var(--color-text-primary); } markdown-style small { font-size: 90%; } markdown-style sub, markdown-style sup { font-size: 75%; line-height: 0; position: relative; vertical-align: baseline; } markdown-style sub { bottom: -0.25em; } markdown-style sup { top: -0.5em; } markdown-style img { border-style: none; max-width: 100%; box-sizing: content-box; background-color: var(--color-canvas-default); } markdown-style code, markdown-style kbd, markdown-style pre, markdown-style samp { font-family: monospace,monospace; font-size: 1em; } markdown-style figure { margin: 1em 40px; } markdown-style hr { box-sizing: content-box; overflow: hidden; background: transparent; border-bottom: 1px solid var(--color-border-muted); height: .25em; padding: 0; margin: 24px 0; background-color: var(--color-border-default); border: 0; } markdown-style input { font: inherit; margin: 0; overflow: visible; font-family: inherit; font-size: inherit; line-height: inherit; } markdown-style [type=button], markdown-style [type=reset], markdown-style [type=submit] { -webkit-appearance: button; } markdown-style [type=button]::-moz-focus-inner, markdown-style [type=reset]::-moz-focus-inner, markdown-style [type=submit]::-moz-focus-inner { border-style: none; padding: 0; } markdown-style [type=button]:-moz-focusring, markdown-style [type=reset]:-moz-focusring, markdown-style [type=submit]:-moz-focusring { outline: 1px dotted ButtonText; } markdown-style [type=checkbox], markdown-style [type=radio] { box-sizing: border-box; padding: 0; } markdown-style [type=number]::-webkit-inner-spin-button, markdown-style [type=number]::-webkit-outer-spin-button { height: auto; } markdown-style [type=search] { -webkit-appearance: textfield; outline-offset: -2px; } markdown-style [type=search]::-webkit-search-cancel-button, markdown-style [type=search]::-webkit-search-decoration { -webkit-appearance: none; } markdown-style ::-webkit-input-placeholder { color: inherit; opacity: .54; } markdown-style ::-webkit-file-upload-button { -webkit-appearance: button; font: inherit; } markdown-style a:hover { text-decoration: underline; } markdown-style hr::before { display: table; content: ""; } markdown-style hr::after { display: table; clear: both; content: ""; } markdown-style table { border-spacing: 0; border-collapse: collapse; display: block; width: max-content; max-width: 100%; overflow: auto; } markdown-style td, markdown-style th { padding: 0; } markdown-style details summary { cursor: pointer; } markdown-style details:not([open])>*:not(summary) { display: none !important; } markdown-style kbd { display: inline-block; padding: 3px 5px; font: 11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; line-height: 10px; color: var(--color-fg-default); vertical-align: middle; background-color: var(--color-canvas-subtle); border: solid 1px var(--color-neutral-muted); border-bottom-color: var(--color-neutral-muted); border-radius: 6px; box-shadow: inset 0 -1px 0 var(--color-neutral-muted); } markdown-style h1, markdown-style h2, markdown-style h3, markdown-style h4, markdown-style h5, markdown-style h6 { margin-top: 24px; margin-bottom: 16px; font-weight: 600; line-height: 1.25; } markdown-style h2 { font-weight: 600; padding-bottom: .3em; font-size: 1.5em; border-bottom: 1px solid var(--color-border-muted); } markdown-style h3 { font-weight: 600; font-size: 1.25em; } markdown-style h4 { font-weight: 600; font-size: 1em; } markdown-style h5 { font-weight: 600; font-size: .875em; } markdown-style h6 { font-weight: 600; font-size: .85em; color: var(--color-fg-muted); } markdown-style p { margin-top: 0; margin-bottom: 10px; } markdown-style blockquote { margin: 0; padding: 0 1em; color: var(--color-fg-muted); border-left: .25em solid var(--color-border-default); } markdown-style ul, markdown-style ol { margin-top: 0; margin-bottom: 0; padding-left: 2em; } markdown-style ol ol, markdown-style ul ol { list-style-type: lower-roman; } markdown-style ul ul ol, markdown-style ul ol ol, markdown-style ol ul ol, markdown-style ol ol ol { list-style-type: lower-alpha; } markdown-style dd { margin-left: 0; } markdown-style tt, markdown-style code { font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; } markdown-style pre { margin-top: 0; margin-bottom: 0; font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; font-size: 12px; word-wrap: normal; } markdown-style .octicon { display: inline-block; overflow: visible !important; vertical-align: text-bottom; fill: currentColor; } markdown-style ::placeholder { color: var(--color-fg-subtle); opacity: 1; } markdown-style input::-webkit-outer-spin-button, markdown-style input::-webkit-inner-spin-button { margin: 0; -webkit-appearance: none; appearance: none; }
|
||
markdown-style .token.comment, markdown-style .token.prolog, markdown-style .token.doctype, markdown-style .token.cdata { color: var(--color-prettylights-syntax-comment); } markdown-style .token.namespace { opacity: 0.7; } markdown-style .token.tag, markdown-style .token.selector, markdown-style .token.constant, markdown-style .token.symbol, markdown-style .token.deleted { color: var(--color-prettylights-syntax-entity-tag); } markdown-style .token.maybe-class-name { color: var(--color-prettylights-syntax-variable); } markdown-style .token.property-access, markdown-style .token.operator, markdown-style .token.boolean, markdown-style .token.number, markdown-style .token.selector markdown-style .token.class, markdown-style .token.attr-name, markdown-style .token.string, markdown-style .token.char, markdown-style .token.builtin { color: var(--color-prettylights-syntax-constant); } markdown-style .token.deleted { color: var(--color-prettylights-syntax-markup-deleted-text); } markdown-style .token.property { color: var(--color-prettylights-syntax-constant); } markdown-style .token.punctuation { color: var(--color-prettylights-syntax-markup-bold); } markdown-style .token.function { color: var(--color-prettylights-syntax-entity); } markdown-style .code-line .token.deleted { background-color: var(--color-prettylights-syntax-markup-deleted-bg); } markdown-style .token.inserted { color: var(--color-prettylights-syntax-markup-inserted-text); } markdown-style .code-line .token.inserted { background-color: var(--color-prettylights-syntax-markup-inserted-bg); } markdown-style .token.variable { color: var(--color-prettylights-syntax-constant); } markdown-style .token.entity, markdown-style .token.url, .language-css markdown-style .token.string, .style markdown-style .token.string { color: var(--color-prettylights-syntax-string); } markdown-style .token.color, markdown-style .token.atrule, markdown-style .token.attr-value, markdown-style .token.function, markdown-style .token.class-name { color: var(--color-prettylights-syntax-string); } markdown-style .token.rule, markdown-style .token.regex, markdown-style .token.important, markdown-style .token.keyword { color: var(--color-prettylights-syntax-keyword); } markdown-style .token.coord { color: var(--color-prettylights-syntax-meta-diff-range); } markdown-style .token.important, markdown-style .token.bold { font-weight: bold; } markdown-style .token.italic { font-style: italic; } markdown-style .token.entity { cursor: help; }
|
||
markdown-style [data-catalyst] { display: block; } markdown-style g-emoji { font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; font-size: 1em; font-style: normal !important; font-weight: 400; line-height: 1; vertical-align: -0.075em; } markdown-style g-emoji img { width: 1em; height: 1em; } markdown-style::before { display: table; content: ""; } markdown-style::after { display: table; clear: both; content: ""; } markdown-style>*:first-child { margin-top: 0 !important; } markdown-style>*:last-child { margin-bottom: 0 !important; } markdown-style a:not([href]) { color: inherit; text-decoration: none; } markdown-style .absent { color: var(--color-danger-fg); } markdown-style a.anchor { float: left; padding-right: 4px; margin-left: -20px; line-height: 1; } markdown-style a.anchor:focus { outline: none; } markdown-style p, markdown-style blockquote, markdown-style ul, markdown-style ol, markdown-style dl, markdown-style table, markdown-style pre, markdown-style details { margin-top: 0; margin-bottom: 16px; } markdown-style blockquote>:first-child { margin-top: 0; } markdown-style blockquote>:last-child { margin-bottom: 0; } markdown-style sup>a::before { content: "["; } markdown-style sup>a::after { content: "]"; }
|
||
markdown-style .octicon-video { border: 1px solid #d0d7de !important; border-radius: 6px !important; display: block; } markdown-style .octicon-video summary { border-bottom: 1px solid #d0d7de !important; padding: 8px 16px !important; cursor: pointer; } markdown-style .octicon-video > video { display: block !important; max-width: 100% !important; padding: 2px; box-sizing: border-box; border-bottom-right-radius: 6px !important; border-bottom-left-radius: 6px !important; } markdown-style details.octicon-video:not([open])>*:not(summary) { display: none !important; } markdown-style details.octicon-video:not([open]) > summary { border-bottom: 0 !important; } markdown-style h1 .octicon-link, markdown-style h2 .octicon-link, markdown-style h3 .octicon-link, markdown-style h4 .octicon-link, markdown-style h5 .octicon-link, markdown-style h6 .octicon-link { color: var(--color-fg-default); vertical-align: middle; visibility: hidden; } markdown-style h1:hover .anchor, markdown-style h2:hover .anchor, markdown-style h3:hover .anchor, markdown-style h4:hover .anchor, markdown-style h5:hover .anchor, markdown-style h6:hover .anchor { text-decoration: none; } markdown-style h1:hover .anchor .octicon-link, markdown-style h2:hover .anchor .octicon-link, markdown-style h3:hover .anchor .octicon-link, markdown-style h4:hover .anchor .octicon-link, markdown-style h5:hover .anchor .octicon-link, markdown-style h6:hover .anchor .octicon-link { visibility: visible; } markdown-style h1 tt, markdown-style h1 code, markdown-style h2 tt, markdown-style h2 code, markdown-style h3 tt, markdown-style h3 code, markdown-style h4 tt, markdown-style h4 code, markdown-style h5 tt, markdown-style h5 code, markdown-style h6 tt, markdown-style h6 code { padding: 0 .2em; font-size: inherit; } markdown-style ul.no-list, markdown-style ol.no-list { padding: 0; list-style-type: none; } markdown-style ol[type="1"] { list-style-type: decimal; } markdown-style ol[type=a] { list-style-type: lower-alpha; } markdown-style ol[type=i] { list-style-type: lower-roman; } markdown-style div>ol:not([type]) { list-style-type: decimal; } markdown-style ul ul, markdown-style ul ol, markdown-style ol ol, markdown-style ol ul { margin-top: 0; margin-bottom: 0; } markdown-style li>p { margin-top: 16px; } markdown-style li+li { margin-top: .25em; } markdown-style dl { padding: 0; } markdown-style dl dt { padding: 0; margin-top: 16px; font-size: 1em; font-style: italic; font-weight: 600; } markdown-style dl dd { padding: 0 16px; margin-bottom: 16px; } markdown-style table th { font-weight: 600; } markdown-style table th, markdown-style table td { padding: 6px 13px; border: 1px solid var(--color-border-default); } markdown-style table tr { background-color: var(--color-canvas-default); border-top: 1px solid var(--color-border-muted); } markdown-style table tr:nth-child(2n) { background-color: var(--color-canvas-subtle); } markdown-style table img { background-color: transparent; vertical-align: middle; } markdown-style img[align=right] { padding-left: 20px; } markdown-style img[align=left] { padding-right: 20px; } markdown-style .emoji { max-width: none; vertical-align: text-top; background-color: transparent; } markdown-style span.frame { display: block; overflow: hidden; } markdown-style span.frame>span { display: block; float: left; width: auto; padding: 7px; margin: 13px 0 0; overflow: hidden; border: 1px solid var(--color-border-default); } markdown-style span.frame span img { display: block; float: left; } markdown-style span.frame span span { display: block; padding: 5px 0 0; clear: both; color: var(--color-fg-default); } markdown-style span.align-center { display: block; overflow: hidden; clear: both; } markdown-style span.align-center>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: center; } markdown-style span.align-center span img { margin: 0 auto; text-align: center; } markdown-style span.align-right { display: block; overflow: hidden; clear: both; } markdown-style span.align-right>span { display: block; margin: 13px 0 0; overflow: hidden; text-align: right; } markdown-style span.align-right span img { margin: 0; text-align: right; } markdown-style span.float-left { display: block; float: left; margin-right: 13px; overflow: hidden; } markdown-style span.float-left span { margin: 13px 0 0; } markdown-style span.float-right { display: block; float: right; margin-left: 13px; overflow: hidden; } markdown-style span.float-right>span { display: block; margin: 13px auto 0; overflow: hidden; text-align: right; } markdown-style code, markdown-style tt { padding: .2em .4em; margin: 0; font-size: 85%; background-color: var(--color-neutral-muted); border-radius: 6px; } markdown-style code br, markdown-style tt br { display: none; } markdown-style del code { text-decoration: inherit; } markdown-style pre code { font-size: 100%; } markdown-style pre>code { padding: 0; margin: 0; word-break: normal; white-space: pre; background: transparent; border: 0; } markdown-style pre { position: relative; font-size: 85%; line-height: 1.45; background-color: var(--color-canvas-subtle); border-radius: 6px; } markdown-style pre code, markdown-style pre tt { display: inline; max-width: auto; padding: 0; margin: 0; overflow: visible; line-height: inherit; word-wrap: normal; background-color: transparent; border: 0; } markdown-style pre > code { padding: 16px; overflow: auto; display: block; } markdown-style .csv-data td, markdown-style .csv-data th { padding: 5px; overflow: hidden; font-size: 12px; line-height: 1; text-align: left; white-space: nowrap; } markdown-style .csv-data .blob-num { padding: 10px 8px 9px; text-align: right; background: var(--color-canvas-default); border: 0; } markdown-style .csv-data tr { border-top: 0; } markdown-style .csv-data th { font-weight: 600; background: var(--color-canvas-subtle); border-top: 0; } markdown-style .footnotes { font-size: 12px; color: var(--color-fg-muted); border-top: 1px solid var(--color-border-default); } markdown-style .footnotes ol { padding-left: 16px; } markdown-style .footnotes li { position: relative; } markdown-style .footnotes li:target::before { position: absolute; top: -8px; right: -8px; bottom: -8px; left: -24px; pointer-events: none; content: ""; border: 2px solid var(--color-accent-emphasis); border-radius: 6px; } markdown-style .footnotes li:target { color: var(--color-fg-default); } markdown-style .footnotes .data-footnote-backref g-emoji { font-family: monospace; } markdown-style .task-list-item { list-style-type: none; } markdown-style .task-list-item label { font-weight: 400; } markdown-style .task-list-item.enabled label { cursor: pointer; } markdown-style .task-list-item+.task-list-item { margin-top: 3px; } markdown-style .task-list-item .handle { display: none; } markdown-style .task-list-item-checkbox, markdown-style input[type="checkbox"] { margin: 0 .2em .25em -1.6em; vertical-align: middle; } markdown-style .contains-task-list:dir(rtl) .task-list-item-checkbox, markdown-style .contains-task-list:dir(rtl) input[type="checkbox"] { margin: 0 -1.6em .25em .2em; } markdown-style ::-webkit-calendar-picker-indicator { filter: invert(50%); }
|
||
</style>
|
||
<slot></slot>
|
||
`;
|
||
class MarkdownStyle extends HTMLElement {
|
||
constructor() {
|
||
super();
|
||
this.shadow = this.attachShadow({ mode: 'open' });
|
||
this.shadow.appendChild(__TEMPLATE__.content.cloneNode(true));
|
||
const style = Array.prototype.slice
|
||
.call(this.shadow.children)
|
||
.find((item) => item.tagName === 'STYLE');
|
||
if (style) {
|
||
const id = '__MARKDOWN_STYLE__';
|
||
const findStyle = document.getElementById(id);
|
||
if (!findStyle) {
|
||
style.id = id;
|
||
document.head.append(style);
|
||
}
|
||
}
|
||
}
|
||
get theme() {
|
||
const value = this.getAttribute('theme');
|
||
return value === null ? '' : value;
|
||
}
|
||
set theme(name) {
|
||
this.setAttribute('theme', name);
|
||
}
|
||
connectedCallback() {
|
||
if (!this.theme) {
|
||
const { colorMode } = document.documentElement.dataset;
|
||
this.theme = colorMode;
|
||
const observer = new MutationObserver((mutationsList, observer) => {
|
||
this.theme = document.documentElement.dataset.colorMode;
|
||
});
|
||
observer.observe(document.documentElement, { attributes: true });
|
||
window.matchMedia('(prefers-color-scheme: light)').onchange = (event) => {
|
||
this.theme = event.matches ? 'light' : 'dark';
|
||
};
|
||
window.matchMedia('(prefers-color-scheme: dark)').onchange = (event) => {
|
||
this.theme = event.matches ? 'dark' : 'light';
|
||
};
|
||
}
|
||
}
|
||
}
|
||
customElements.define('markdown-style', MarkdownStyle);</script><markdown-style style="max-width: 960px; margin: 0 auto 60px auto; padding: 8px;" class="markdown-style">
|
||
<h1 id="git"><a class="anchor" aria-hidden="true" tabindex="-1" href="#git"><span class="octicon octicon-link"></span></a>git</h1>
|
||
<p>是目前世界上最先进的分布式版本控制系统</p>
|
||
<h2 id="补充说明"><a class="anchor" aria-hidden="true" tabindex="-1" href="#补充说明"><span class="octicon octicon-link"></span></a>补充说明</h2>
|
||
<p><strong>git命令</strong> 很多人都知道,Linus在1991年创建了开源的Linux,从此,Linux系统不断发展,已经成为最大的服务器系统软件了。</p>
|
||
<p>Linus虽然创建了Linux,但Linux的壮大是靠全世界热心的志愿者参与的,这么多人在世界各地为Linux编写代码,那Linux的代码是如何管理的呢?</p>
|
||
<p>事实是,在2002年以前,世界各地的志愿者把源代码文件通过diff的方式发给Linus,然后由Linus本人通过手工方式合并代码!</p>
|
||
<p>你也许会想,为什么Linus不把Linux代码放到版本控制系统里呢?不是有CVS、SVN这些免费的版本控制系统吗?因为Linus坚定地反对CVS和SVN,这些集中式的版本控制系统不但速度慢,而且必须联网才能使用。有一些商用的版本控制系统,虽然比CVS、SVN好用,但那是付费的,和Linux的开源精神不符。</p>
|
||
<p>不过,到了2002年,Linux系统已经发展了十年了,代码库之大让Linus很难继续通过手工方式管理了,社区的弟兄们也对这种方式表达了强烈不满,于是Linus选择了一个商业的版本控制系统BitKeeper,BitKeeper的东家BitMover公司出于人道主义精神,授权Linux社区免费使用这个版本控制系统。</p>
|
||
<p>安定团结的大好局面在2005年就被打破了,原因是Linux社区牛人聚集,不免沾染了一些梁山好汉的江湖习气。开发Samba的Andrew试图破解BitKeeper的协议(这么干的其实也不只他一个),被BitMover公司发现了(监控工作做得不错!),于是BitMover公司怒了,要收回Linux社区的免费使用权。</p>
|
||
<p>Linus可以向BitMover公司道个歉,保证以后严格管教弟兄们,嗯,这是不可能的。实际情况是这样的:</p>
|
||
<p>Linus花了两周时间自己用C写了一个分布式版本控制系统,这就是Git!一个月之内,Linux系统的源码已经由Git管理了!牛是怎么定义的呢?大家可以体会一下。</p>
|
||
<p>Git迅速成为最流行的分布式版本控制系统,尤其是2008年,GitHub网站上线了,它为开源项目免费提供Git存储,无数开源项目开始迁移至GitHub,包括jQuery,PHP,Ruby等等。</p>
|
||
<p>历史就是这么偶然,如果不是当年BitMover公司威胁Linux社区,可能现在我们就没有免费而超级好用的Git了。</p>
|
||
<p><a href="https://github.com/jaywcjlove/handbook/blob/master/other/Git%E5%B8%B8%E7%94%A8%E5%91%BD%E4%BB%A4%E6%B8%85%E5%8D%95.md">Git常用命令清单</a></p>
|
||
<h3 id="语法"><a class="anchor" aria-hidden="true" tabindex="-1" href="#语法"><span class="octicon octicon-link"></span></a>语法</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token punctuation">[</span>--version<span class="token punctuation">]</span> <span class="token punctuation">[</span>--help<span class="token punctuation">]</span> <span class="token punctuation">[</span>-C <span class="token operator"><</span>path<span class="token operator">></span><span class="token punctuation">]</span> <span class="token punctuation">[</span>-c <span class="token assign-left variable">name</span><span class="token operator">=</span>value<span class="token punctuation">]</span> <span class="token punctuation">[</span>--exec-path<span class="token punctuation">[</span><span class="token operator">=</span><span class="token operator"><</span>path<span class="token operator">></span><span class="token punctuation">]</span><span class="token punctuation">]</span> <span class="token punctuation">[</span>--html-path<span class="token punctuation">]</span> <span class="token punctuation">[</span>--man-path<span class="token punctuation">]</span> <span class="token punctuation">[</span>--info-path<span class="token punctuation">]</span> <span class="token punctuation">[</span>-p <span class="token operator">|</span> <span class="token parameter variable">--paginate</span> <span class="token operator">|</span> --no-pager<span class="token punctuation">]</span> <span class="token punctuation">[</span>--no-replace-objects<span class="token punctuation">]</span> <span class="token punctuation">[</span>--bare<span class="token punctuation">]</span> <span class="token punctuation">[</span>--git-dir<span class="token operator">=</span><span class="token operator"><</span>path<span class="token operator">></span><span class="token punctuation">]</span> <span class="token punctuation">[</span>--work-tree<span class="token operator">=</span><span class="token operator"><</span>path<span class="token operator">></span><span class="token punctuation">]</span> <span class="token punctuation">[</span>--namespace<span class="token operator">=</span><span class="token operator"><</span>name<span class="token operator">></span><span class="token punctuation">]</span> <span class="token operator"><</span>command<span class="token operator">></span> <span class="token punctuation">[</span><span class="token operator"><</span>args<span class="token operator">></span><span class="token punctuation">]</span>
|
||
</span></code><div onclick="copied(this)" data-code="git [--version] [--help] [-C <path>] [-c name=value] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path] [-p | --paginate | --no-pager] [--no-replace-objects] [--bare] [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>] <command> [<args>]
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="选项"><a class="anchor" aria-hidden="true" tabindex="-1" href="#选项"><span class="octicon octicon-link"></span></a>选项</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">add</span> 将文件内容添加到索引
|
||
</span><span class="code-line line-number" line="2">bisect 通过二进制查找引入错误的更改
|
||
</span><span class="code-line line-number" line="3">branch 列出,创建或删除分支
|
||
</span><span class="code-line line-number" line="4">checkout 检查分支或路径到工作树
|
||
</span><span class="code-line line-number" line="5">clone 将存储库克隆到新目录中
|
||
</span><span class="code-line line-number" line="6">commit 将更改记录到存储库
|
||
</span><span class="code-line line-number" line="7"><span class="token function">diff</span> 显示提交,提交和工作树等之间的更改
|
||
</span><span class="code-line line-number" line="8">fetch 从另一个存储库下载对象和引用
|
||
</span><span class="code-line line-number" line="9"><span class="token function">grep</span> 打印匹配图案的行
|
||
</span><span class="code-line line-number" line="10">init 创建一个空的Git仓库或重新初始化一个现有的
|
||
</span><span class="code-line line-number" line="11">log 显示提交日志
|
||
</span><span class="code-line line-number" line="12">merge 加入两个或更多的开发历史
|
||
</span><span class="code-line line-number" line="13"><span class="token function">mv</span> 移动或重命名文件,目录或符号链接
|
||
</span><span class="code-line line-number" line="14">pull 从另一个存储库或本地分支获取并合并
|
||
</span><span class="code-line line-number" line="15">push 更新远程引用以及相关对象
|
||
</span><span class="code-line line-number" line="16">rebase 转发端口本地提交到更新的上游头
|
||
</span><span class="code-line line-number" line="17">reset 将当前HEAD复位到指定状态
|
||
</span><span class="code-line line-number" line="18"><span class="token function">rm</span> 从工作树和索引中删除文件
|
||
</span><span class="code-line line-number" line="19">show 显示各种类型的对象
|
||
</span><span class="code-line line-number" line="20">status 显示工作树状态
|
||
</span><span class="code-line line-number" line="21">tag 创建,列出,删除或验证使用GPG签名的标签对象
|
||
</span></code><div onclick="copied(this)" data-code="add 将文件内容添加到索引
|
||
bisect 通过二进制查找引入错误的更改
|
||
branch 列出,创建或删除分支
|
||
checkout 检查分支或路径到工作树
|
||
clone 将存储库克隆到新目录中
|
||
commit 将更改记录到存储库
|
||
diff 显示提交,提交和工作树等之间的更改
|
||
fetch 从另一个存储库下载对象和引用
|
||
grep 打印匹配图案的行
|
||
init 创建一个空的Git仓库或重新初始化一个现有的
|
||
log 显示提交日志
|
||
merge 加入两个或更多的开发历史
|
||
mv 移动或重命名文件,目录或符号链接
|
||
pull 从另一个存储库或本地分支获取并合并
|
||
push 更新远程引用以及相关对象
|
||
rebase 转发端口本地提交到更新的上游头
|
||
reset 将当前HEAD复位到指定状态
|
||
rm 从工作树和索引中删除文件
|
||
show 显示各种类型的对象
|
||
status 显示工作树状态
|
||
tag 创建,列出,删除或验证使用GPG签名的标签对象
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="例子"><a class="anchor" aria-hidden="true" tabindex="-1" href="#例子"><span class="octicon octicon-link"></span></a>例子</h3>
|
||
<p>init</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> init <span class="token comment"># 初始化</span>
|
||
</span></code><div onclick="copied(this)" data-code="git init # 初始化
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>status</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> status <span class="token comment"># 获取状态</span>
|
||
</span></code><div onclick="copied(this)" data-code="git status # 获取状态
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>add</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token function">add</span> <span class="token function">file</span> <span class="token comment"># .或*代表全部添加</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">--cached</span> <span class="token operator"><</span>added_file_to_undo<span class="token operator">></span> <span class="token comment"># 在commit之前撤销git add操作</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> reset <span class="token function">head</span> <span class="token comment"># 好像比上面`git rm --cached`更方便</span>
|
||
</span></code><div onclick="copied(this)" data-code="git add file # .或*代表全部添加
|
||
git rm --cached <added_file_to_undo> # 在commit之前撤销git add操作
|
||
git reset head # 好像比上面`git rm --cached`更方便
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>commit</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">"message"</span> <span class="token comment"># 此处注意乱码</span>
|
||
</span></code><div onclick="copied(this)" data-code="git commit -m "message" # 此处注意乱码
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>remote</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote <span class="token function">add</span> origin git@github.com:JSLite/test.git <span class="token comment"># 添加源</span>
|
||
</span></code><div onclick="copied(this)" data-code="git remote add origin git@github.com:JSLite/test.git # 添加源
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>push</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push <span class="token parameter variable">-u</span> origin master <span class="token comment"># push 同时设置默认跟踪分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push origin master
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master <span class="token comment"># 强制推送文件,缩写 -f(全写--force)</span>
|
||
</span></code><div onclick="copied(this)" data-code="git push -u origin master # push 同时设置默认跟踪分支
|
||
git push origin master
|
||
git push -f origin master # 强制推送文件,缩写 -f(全写--force)
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>clone</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone git://github.com/JSLite/JSLite.js.git
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> clone git://github.com/JSLite/JSLite.js.git mypro <span class="token comment"># 克隆到自定义文件夹</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> clone <span class="token punctuation">[</span>user@<span class="token punctuation">]</span>example.com:path/to/repo.git/ <span class="token comment"># SSH协议还有另一种写法。</span>
|
||
</span></code><div onclick="copied(this)" data-code="git clone git://github.com/JSLite/JSLite.js.git
|
||
git clone git://github.com/JSLite/JSLite.js.git mypro # 克隆到自定义文件夹
|
||
git clone [user@]example.com:path/to/repo.git/ # SSH协议还有另一种写法。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。<code>git clone <版本库的网址> <本地目录名></code></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone http<span class="token punctuation">[</span>s<span class="token punctuation">]</span>://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> clone ssh://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> clone git://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> clone /opt/git/project.git
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> clone file:///opt/git/project.git
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> clone ftp<span class="token punctuation">[</span>s<span class="token punctuation">]</span>://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> clone rsync://example.com/path/to/repo.git/
|
||
</span></code><div onclick="copied(this)" data-code="git clone http[s]://example.com/path/to/repo.git/
|
||
git clone ssh://example.com/path/to/repo.git/
|
||
git clone git://example.com/path/to/repo.git/
|
||
git clone /opt/git/project.git
|
||
git clone file:///opt/git/project.git
|
||
git clone ftp[s]://example.com/path/to/repo.git/
|
||
git clone rsync://example.com/path/to/repo.git/
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="配置"><a class="anchor" aria-hidden="true" tabindex="-1" href="#配置"><span class="octicon octicon-link"></span></a>配置</h2>
|
||
<p>首先是配置帐号信息 <code>ssh -T git@github.com</code> 测试。</p>
|
||
<h2 id="修改项目中的个人信息"><a class="anchor" aria-hidden="true" tabindex="-1" href="#修改项目中的个人信息"><span class="octicon octicon-link"></span></a>修改项目中的个人信息</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token builtin class-name">help</span> config <span class="token comment"># 获取帮助信息,查看修改个人信息的参数 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> config <span class="token parameter variable">--global</span> user.name <span class="token string">"小弟调调"</span> <span class="token comment"># 修改全局名字</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> config <span class="token parameter variable">--global</span> user.email <span class="token string">"wowohoo@qq.com"</span> <span class="token comment"># 修改全局邮箱</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> config <span class="token parameter variable">--list</span> <span class="token comment"># 查看配置的信息 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git help config # 获取帮助信息,查看修改个人信息的参数
|
||
git config --global user.name "小弟调调" # 修改全局名字
|
||
git config --global user.email "wowohoo@qq.com" # 修改全局邮箱
|
||
git config --list # 查看配置的信息
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="配置自动换行"><a class="anchor" aria-hidden="true" tabindex="-1" href="#配置自动换行"><span class="octicon octicon-link"></span></a>配置自动换行</h3>
|
||
<p>自动转换坑太大,提交到git是自动将换行符转换为lf</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config <span class="token parameter variable">--global</span> core.autocrlf input
|
||
</span></code><div onclick="copied(this)" data-code="git config --global core.autocrlf input
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="常见使用场景"><a class="anchor" aria-hidden="true" tabindex="-1" href="#常见使用场景"><span class="octicon octicon-link"></span></a>常见使用场景</h2>
|
||
<h3 id="创建ssh密钥"><a class="anchor" aria-hidden="true" tabindex="-1" href="#创建ssh密钥"><span class="octicon octicon-link"></span></a>创建SSH密钥</h3>
|
||
<p>这个密钥用来跟 github 通信,在本地终端里生成然后上传到 github</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-C</span> <span class="token string">'wowohoo@qq.com'</span> <span class="token comment"># 生成密钥 </span>
|
||
</span><span class="code-line line-number" line="2">ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-C</span> <span class="token string">"wowohoo@qq.com"</span> <span class="token parameter variable">-f</span> ~/.ssh/ww_rsa <span class="token comment"># 指定生成目录文件名字</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">ssh</span> <span class="token parameter variable">-T</span> git@github.com <span class="token comment"># 测试是否成功 </span>
|
||
</span></code><div onclick="copied(this)" data-code="ssh-keygen -t rsa -C 'wowohoo@qq.com' # 生成密钥
|
||
ssh-keygen -t rsa -C "wowohoo@qq.com" -f ~/.ssh/ww_rsa # 指定生成目录文件名字
|
||
ssh -T git@github.com # 测试是否成功
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="多账号ssh配置"><a class="anchor" aria-hidden="true" tabindex="-1" href="#多账号ssh配置"><span class="octicon octicon-link"></span></a>多账号ssh配置</h3>
|
||
<p><strong>1.生成指定名字的密钥</strong></p>
|
||
<p><code>ssh-keygen -t rsa -C "邮箱地址" -f ~/.ssh/jslite_rsa</code><br>会生成 <code>jslite_rsa</code> 和 <code>jslite_rsa.pub</code> 这两个文件</p>
|
||
<p><strong>2.密钥复制到托管平台上</strong></p>
|
||
<p>
|
||
<code>vim ~/.ssh/jslite_rsa.pub</code>
|
||
打开公钥文件 <code>jslite_rsa.pub</code> ,并把内容复制至代码托管平台上
|
||
</p>
|
||
<p><strong>3.修改config文件</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">vim</span> ~/.ssh/config <span class="token comment"># 修改config文件,如果没有创建 `config`</span>
|
||
</span></code><div onclick="copied(this)" data-code="vim ~/.ssh/config # 修改config文件,如果没有创建 `config`
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">Host jslite.github.com
|
||
</span><span class="code-line line-number" line="2"> HostName github.com
|
||
</span><span class="code-line line-number" line="3"> User <span class="token function">git</span>
|
||
</span><span class="code-line line-number" line="4"> IdentityFile ~/.ssh/jslite_rsa
|
||
</span><span class="code-line line-number" line="5">
|
||
</span><span class="code-line line-number" line="6">Host work.github.com
|
||
</span><span class="code-line line-number" line="7"> HostName github.com
|
||
</span><span class="code-line line-number" line="8"> <span class="token comment"># Port 服务器open-ssh端口(默认:22,默认时一般不写此行)</span>
|
||
</span><span class="code-line line-number" line="9"> <span class="token comment"># PreferredAuthentications 配置登录时用什么权限认证 </span>
|
||
</span><span class="code-line line-number" line="10"> <span class="token comment"># publickey|password publickey|keyboard-interactive等</span>
|
||
</span><span class="code-line line-number" line="11"> User <span class="token function">git</span>
|
||
</span><span class="code-line line-number" line="12"> IdentityFile ~/.ssh/work_rsa
|
||
</span></code><div onclick="copied(this)" data-code="Host jslite.github.com
|
||
HostName github.com
|
||
User git
|
||
IdentityFile ~/.ssh/jslite_rsa
|
||
|
||
Host work.github.com
|
||
HostName github.com
|
||
# Port 服务器open-ssh端口(默认:22,默认时一般不写此行)
|
||
# PreferredAuthentications 配置登录时用什么权限认证
|
||
# publickey|password publickey|keyboard-interactive等
|
||
User git
|
||
IdentityFile ~/.ssh/work_rsa
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<ul>
|
||
<li><code>Host</code> 这里是个别名可以随便命名</li>
|
||
<li><code>HostName</code> 一般是网站如:<code>git@ss.github.com:username/repo.git</code> 填写 <code>github.com</code></li>
|
||
<li><code>User</code> 通常填写<code>git</code></li>
|
||
<li><code>IdentityFile</code> 使用的公钥文件地址</li>
|
||
</ul>
|
||
<p><strong>4.测试</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">ssh</span> <span class="token parameter variable">-T</span> git@jslite.github.com <span class="token comment"># `@`后面跟上定义的Host </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">ssh</span> <span class="token parameter variable">-T</span> work.github.com <span class="token comment"># 通过别名测试</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">ssh</span> <span class="token parameter variable">-i</span> ~/公钥文件地址 Host别名 <span class="token comment"># 如 ssh -i ~/.ssh/work_rsa work.github.com</span>
|
||
</span></code><div onclick="copied(this)" data-code="ssh -T git@jslite.github.com # `@`后面跟上定义的Host
|
||
ssh -T work.github.com # 通过别名测试
|
||
ssh -i ~/公钥文件地址 Host别名 # 如 ssh -i ~/.ssh/work_rsa work.github.com
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>5.使用</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 原来的写法</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> clone git@github.com:<span class="token operator"><</span>jslite的用户名<span class="token operator">></span>/learngit.git
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># 现在的写法</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> clone git@jslite.github.com:<span class="token operator"><</span>jslite的用户名<span class="token operator">></span>/learngit.git
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> clone git@work.github.com:<span class="token operator"><</span>work的用户名<span class="token operator">></span>/learngit.git
|
||
</span></code><div onclick="copied(this)" data-code="# 原来的写法
|
||
git clone git@github.com:<jslite的用户名>/learngit.git
|
||
# 现在的写法
|
||
git clone git@jslite.github.com:<jslite的用户名>/learngit.git
|
||
git clone git@work.github.com:<work的用户名>/learngit.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>5.注意</strong></p>
|
||
<p>如果你修改了id_rsa的名字,你需要将ssh key添加到SSH agent中,如:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">ssh-add ~/.ssh/jslite_rsa
|
||
</span><span class="code-line line-number" line="2">ssh-add <span class="token parameter variable">-l</span> <span class="token comment"># 查看所有的key</span>
|
||
</span><span class="code-line line-number" line="3">ssh-add <span class="token parameter variable">-D</span> <span class="token comment"># 删除所有的key</span>
|
||
</span><span class="code-line line-number" line="4">ssh-add <span class="token parameter variable">-d</span> ~/.ssh/jslite_rsa <span class="token comment"># 删除指定的key</span>
|
||
</span></code><div onclick="copied(this)" data-code="ssh-add ~/.ssh/jslite_rsa
|
||
ssh-add -l # 查看所有的key
|
||
ssh-add -D # 删除所有的key
|
||
ssh-add -d ~/.ssh/jslite_rsa # 删除指定的key
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="免密码登录远程服务器"><a class="anchor" aria-hidden="true" tabindex="-1" href="#免密码登录远程服务器"><span class="octicon octicon-link"></span></a>免密码登录远程服务器</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">ssh-keygen <span class="token parameter variable">-t</span> rsa <span class="token parameter variable">-P</span> <span class="token string">''</span> <span class="token parameter variable">-f</span> ~/.ssh/aliyunserver.key
|
||
</span><span class="code-line line-number" line="2">ssh-copy-id <span class="token parameter variable">-i</span> ~/.ssh/aliyunserver.key.pub root@192.168.182.112 <span class="token comment"># 这里需要输入密码一次</span>
|
||
</span></code><div onclick="copied(this)" data-code="ssh-keygen -t rsa -P '' -f ~/.ssh/aliyunserver.key
|
||
ssh-copy-id -i ~/.ssh/aliyunserver.key.pub root@192.168.182.112 # 这里需要输入密码一次
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>编辑 <code>~/.ssh/config</code></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">Host aliyun1
|
||
</span><span class="code-line line-number" line="2"> HostName <span class="token number">192.168</span>.182.112
|
||
</span><span class="code-line line-number" line="3"> User root
|
||
</span><span class="code-line line-number" line="4"> PreferredAuthentications publickey
|
||
</span><span class="code-line line-number" line="5"> IdentityFile ~/.ssh/aliyunserver.key
|
||
</span></code><div onclick="copied(this)" data-code="Host aliyun1
|
||
HostName 192.168.182.112
|
||
User root
|
||
PreferredAuthentications publickey
|
||
IdentityFile ~/.ssh/aliyunserver.key
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>上面配置完了,可以通过命令登录,不需要输入IP地址和密码 <code>ssh aliyun1</code></p>
|
||
<h3 id="https协议下提交代码免密码"><a class="anchor" aria-hidden="true" tabindex="-1" href="#https协议下提交代码免密码"><span class="octicon octicon-link"></span></a>https协议下提交代码免密码</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone https://github.com/username/rep.git
|
||
</span></code><div onclick="copied(this)" data-code="git clone https://github.com/username/rep.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>通过上面方式克隆可能需要密码,解决办法:进入当前克隆的项目 <code>vi rep/.git/config</code> 编辑 <code>config</code>, 按照下面方式修改,你就可以提交代码不用输入密码了。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token punctuation">[</span>core<span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="2"> repositoryformatversion <span class="token operator">=</span> <span class="token number">0</span>
|
||
</span><span class="code-line line-number" line="3"> filemode <span class="token operator">=</span> <span class="token boolean">true</span>
|
||
</span><span class="code-line line-number" line="4"> bare <span class="token operator">=</span> <span class="token boolean">false</span>
|
||
</span><span class="code-line line-number" line="5"> logallrefupdates <span class="token operator">=</span> <span class="token boolean">true</span>
|
||
</span><span class="code-line line-number" line="6"> ignorecase <span class="token operator">=</span> <span class="token boolean">true</span>
|
||
</span><span class="code-line line-number" line="7"> precomposeunicode <span class="token operator">=</span> <span class="token boolean">true</span>
|
||
</span><span class="code-line line-number" line="8"><span class="token punctuation">[</span>remote <span class="token string">"origin"</span><span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="9">- url <span class="token operator">=</span> https://github.com/username/rep.git
|
||
</span><span class="code-line line-number" line="10">+ url <span class="token operator">=</span> https://用户名:密码@github.com/username/rep.git
|
||
</span><span class="code-line line-number" line="11"> fetch <span class="token operator">=</span> +refs/heads/*:refs/remotes/origin/*
|
||
</span><span class="code-line line-number" line="12"><span class="token punctuation">[</span>branch <span class="token string">"master"</span><span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="13"> remote <span class="token operator">=</span> origin
|
||
</span><span class="code-line line-number" line="14"> merge <span class="token operator">=</span> refs/heads/master
|
||
</span></code><div onclick="copied(this)" data-code="[core]
|
||
repositoryformatversion = 0
|
||
filemode = true
|
||
bare = false
|
||
logallrefupdates = true
|
||
ignorecase = true
|
||
precomposeunicode = true
|
||
[remote "origin"]
|
||
- url = https://github.com/username/rep.git
|
||
+ url = https://用户名:密码@github.com/username/rep.git
|
||
fetch = +refs/heads/*:refs/remotes/origin/*
|
||
[branch "master"]
|
||
remote = origin
|
||
merge = refs/heads/master
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="文件推向3个git库"><a class="anchor" aria-hidden="true" tabindex="-1" href="#文件推向3个git库"><span class="octicon octicon-link"></span></a>文件推向3个git库</h3>
|
||
<p><strong>1. 增加3个远程库地址</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote <span class="token function">add</span> origin https://github.com/JSLite/JSLite.git
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> remote set-url <span class="token parameter variable">--add</span> origin https://gitlab.com/wang/JSLite.js.git
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> remote set-url <span class="token parameter variable">--add</span> origin https://oschina.net/wang/JSLite.js.git
|
||
</span></code><div onclick="copied(this)" data-code="git remote add origin https://github.com/JSLite/JSLite.git
|
||
git remote set-url --add origin https://gitlab.com/wang/JSLite.js.git
|
||
git remote set-url --add origin https://oschina.net/wang/JSLite.js.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>2. 删除其中一个 set-url 地址</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">usage: <span class="token function">git</span> remote set-url <span class="token punctuation">[</span>--push<span class="token punctuation">]</span> <span class="token operator"><</span>name<span class="token operator">></span> <span class="token operator"><</span>newurl<span class="token operator">></span> <span class="token punctuation">[</span><span class="token operator"><</span>oldurl<span class="token operator">></span><span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="2"> or: <span class="token function">git</span> remote set-url <span class="token parameter variable">--add</span> <span class="token operator"><</span>name<span class="token operator">></span> <span class="token operator"><</span>newurl<span class="token operator">></span>
|
||
</span><span class="code-line line-number" line="3"> or: <span class="token function">git</span> remote set-url <span class="token parameter variable">--delete</span> <span class="token operator"><</span>name<span class="token operator">></span> <span class="token operator"><</span>url<span class="token operator">></span>
|
||
</span></code><div onclick="copied(this)" data-code="usage: git remote set-url [--push] <name> <newurl> [<oldurl>]
|
||
or: git remote set-url --add <name> <newurl>
|
||
or: git remote set-url --delete <name> <url>
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote set-url <span class="token parameter variable">--delete</span> origin https://oschina.net/wang/JSLite.js.git
|
||
</span></code><div onclick="copied(this)" data-code="git remote set-url --delete origin https://oschina.net/wang/JSLite.js.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>3.推送代码</strong></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push origin master
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master <span class="token comment"># 强制推送 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git push origin master
|
||
git push -f origin master # 强制推送
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>4.拉代码</strong></p>
|
||
<p>只能拉取 <code>origin</code> 里的一个url地址,这个fetch-url<br>默认为你添加的到 <code>origin</code>的第一个地址</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> pull origin master
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> pull <span class="token parameter variable">--all</span> <span class="token comment"># 获取远程所有内容包括tag </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> pull origin next:master <span class="token comment"># 取回origin主机的next分支,与本地的master分支合并 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> pull origin next <span class="token comment"># 远程分支是与当前分支合并 </span>
|
||
</span><span class="code-line line-number" line="5">
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># 上面一条命令等同于下面两条命令 </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> fetch origin
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> merge origin/next
|
||
</span></code><div onclick="copied(this)" data-code="git pull origin master
|
||
git pull --all # 获取远程所有内容包括tag
|
||
git pull origin next:master # 取回origin主机的next分支,与本地的master分支合并
|
||
git pull origin next # 远程分支是与当前分支合并
|
||
|
||
# 上面一条命令等同于下面两条命令
|
||
git fetch origin
|
||
git merge origin/next
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>如果远程主机删除了某个分支,默认情况下,git pull 不会在拉取远程分支的时候,删除对应的本地分支。这是为了防止,由于其他人操作了远程主机,导致git pull不知不觉删除了本地分支。<br>但是,你可以改变这个行为,加上参数 -p 就会在本地删除远程已经删除的分支。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> pull <span class="token parameter variable">-p</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># 等同于下面的命令</span>
|
||
</span><span class="code-line line-number" line="3">$ <span class="token function">git</span> fetch <span class="token parameter variable">--prune</span> origin
|
||
</span><span class="code-line line-number" line="4">$ <span class="token function">git</span> fetch <span class="token parameter variable">-p</span>
|
||
</span></code><div onclick="copied(this)" data-code="$ git pull -p
|
||
# 等同于下面的命令
|
||
$ git fetch --prune origin
|
||
$ git fetch -p
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>5.更改pull</strong></p>
|
||
<p>只需要更改config文件里,那三个url的顺序即可,fetch-url会直接对应排行第一的那个utl连接。</p>
|
||
<h3 id="修改远程仓库地址"><a class="anchor" aria-hidden="true" tabindex="-1" href="#修改远程仓库地址"><span class="octicon octicon-link"></span></a>修改远程仓库地址</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote remove origin <span class="token comment"># 删除该远程路径 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> remote <span class="token function">add</span> origin git@jslite.github.com:JSLite/JSLite.git <span class="token comment"># 添加远程路径 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git remote remove origin # 删除该远程路径
|
||
git remote add origin git@jslite.github.com:JSLite/JSLite.git # 添加远程路径
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="撤销远程记录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#撤销远程记录"><span class="octicon octicon-link"></span></a>撤销远程记录</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> reset <span class="token parameter variable">--hard</span> HEAD~1 <span class="token comment"># 撤销一条记录 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin HEAD:master <span class="token comment"># 同步到远程仓库 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git reset --hard HEAD~1 # 撤销一条记录
|
||
git push -f origin HEAD:master # 同步到远程仓库
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="放弃本地的文件修改"><a class="anchor" aria-hidden="true" tabindex="-1" href="#放弃本地的文件修改"><span class="octicon octicon-link"></span></a>放弃本地的文件修改</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> reset <span class="token parameter variable">--hard</span> FETCH_HEAD <span class="token comment"># FETCH_HEAD表示上一次成功git pull之后形成的commit点。然后git pull</span>
|
||
</span></code><div onclick="copied(this)" data-code="git reset --hard FETCH_HEAD # FETCH_HEAD表示上一次成功git pull之后形成的commit点。然后git pull
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><code>git reset --hard FETCH_HEAD</code> 出现错误</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> pull
|
||
</span><span class="code-line line-number" line="2">You are not currently on a branch, so I cannot use any
|
||
</span><span class="code-line line-number" line="3"><span class="token string">'branch.<branchname>.merge'</span> <span class="token keyword">in</span> your configuration file.
|
||
</span><span class="code-line line-number" line="4">Please specify <span class="token function">which</span> remote branch you want to use on the <span class="token builtin class-name">command</span>
|
||
</span><span class="code-line line-number" line="5">line and try again <span class="token punctuation">(</span>e.g. <span class="token string">'git pull <repository> <refspec>'</span><span class="token punctuation">)</span>.
|
||
</span><span class="code-line line-number" line="6">See git-pull<span class="token punctuation">(</span><span class="token number">1</span><span class="token punctuation">)</span> FOR details.
|
||
</span></code><div onclick="copied(this)" data-code="git pull
|
||
You are not currently on a branch, so I cannot use any
|
||
'branch.<branchname>.merge' in your configuration file.
|
||
Please specify which remote branch you want to use on the command
|
||
line and try again (e.g. 'git pull <repository> <refspec>').
|
||
See git-pull(1) FOR details.
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>解决方法:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> temp <span class="token comment"># 新建+切换到temp分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> checkout master
|
||
</span></code><div onclick="copied(this)" data-code="git checkout -b temp # 新建+切换到temp分支
|
||
git checkout master
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="最简单放弃本地修改内容"><a class="anchor" aria-hidden="true" tabindex="-1" href="#最简单放弃本地修改内容"><span class="octicon octicon-link"></span></a>最简单放弃本地修改内容</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 如果有的修改以及加入暂存区的话</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> reset <span class="token parameter variable">--hard</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># 还原所有修改,不会删除新增的文件</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> checkout <span class="token builtin class-name">.</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># 下面命令会删除新增的文件</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> clean <span class="token parameter variable">-xdf</span>
|
||
</span></code><div onclick="copied(this)" data-code="# 如果有的修改以及加入暂存区的话
|
||
git reset --hard
|
||
# 还原所有修改,不会删除新增的文件
|
||
git checkout .
|
||
# 下面命令会删除新增的文件
|
||
git clean -xdf
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>通过存储暂存区stash,在删除暂存区的方法放弃本地修改。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> stash <span class="token operator">&&</span> <span class="token function">git</span> stash drop
|
||
</span></code><div onclick="copied(this)" data-code="git stash && git stash drop
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="回滚到某个commit提交"><a class="anchor" aria-hidden="true" tabindex="-1" href="#回滚到某个commit提交"><span class="octicon octicon-link"></span></a>回滚到某个commit提交</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> revert HEAD~1 <span class="token comment"># 撤销一条记录 会弹出 commit 编辑</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push <span class="token comment"># 提交回滚</span>
|
||
</span></code><div onclick="copied(this)" data-code="git revert HEAD~1 # 撤销一条记录 会弹出 commit 编辑
|
||
git push # 提交回滚
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="回退到某一个版本"><a class="anchor" aria-hidden="true" tabindex="-1" href="#回退到某一个版本"><span class="octicon octicon-link"></span></a>回退到某一个版本</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> reset <span class="token parameter variable">--hard</span> <span class="token operator"><</span>hash<span class="token operator">></span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># 例如 git reset --hard a3hd73r</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># --hard代表丢弃工作区的修改,让工作区与版本代码一模一样,与之对应,</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># --soft参数代表保留工作区的修改。</span>
|
||
</span></code><div onclick="copied(this)" data-code="git reset --hard <hash>
|
||
# 例如 git reset --hard a3hd73r
|
||
# --hard代表丢弃工作区的修改,让工作区与版本代码一模一样,与之对应,
|
||
# --soft参数代表保留工作区的修改。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="去掉某个commit"><a class="anchor" aria-hidden="true" tabindex="-1" href="#去掉某个commit"><span class="octicon octicon-link"></span></a>去掉某个commit</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 实质是新建了一个与原来完全相反的commit,抵消了原来commit的效果</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> revert <span class="token operator"><</span>commit-hash<span class="token operator">></span>
|
||
</span></code><div onclick="copied(this)" data-code="# 实质是新建了一个与原来完全相反的commit,抵消了原来commit的效果
|
||
git revert <commit-hash>
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="新建一个空分支"><a class="anchor" aria-hidden="true" tabindex="-1" href="#新建一个空分支"><span class="octicon octicon-link"></span></a>新建一个空分支</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 这种方式新建的分支(gh-pages)是没有 commit 记录的</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> checkout <span class="token parameter variable">--orphan</span> gh-pages
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># 删除新建的gh-pages分支原本的内容,如果不删除,提交将作为当前分支的第一个commit</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">-rf</span> <span class="token builtin class-name">.</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># 查看一下状态 有可能上面一条命令,没有删除还没有提交的的文件</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> state
|
||
</span></code><div onclick="copied(this)" data-code="# 这种方式新建的分支(gh-pages)是没有 commit 记录的
|
||
git checkout --orphan gh-pages
|
||
# 删除新建的gh-pages分支原本的内容,如果不删除,提交将作为当前分支的第一个commit
|
||
git rm -rf .
|
||
# 查看一下状态 有可能上面一条命令,没有删除还没有提交的的文件
|
||
git state
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="合并多个commit"><a class="anchor" aria-hidden="true" tabindex="-1" href="#合并多个commit"><span class="octicon octicon-link"></span></a>合并多个commit</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># 这个命令,将最近4个commit合并为1个,HEAD代表当前版本。</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># 将进入VIM界面,你可以修改提交信息。</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> rebase <span class="token parameter variable">-i</span> HEAD~4
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># 可以看到其中分为两个部分,上方未注释的部分是填写要执行的指令,</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># 而下方注释的部分则是指令的提示说明。指令部分中由前方的命令名称、commit hash 和 commit message 组成</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># 当前我们只要知道 pick 和 squash 这两个命令即可。</span>
|
||
</span><span class="code-line line-number" line="7"><span class="token comment"># --> pick 的意思是要会执行这个 commit</span>
|
||
</span><span class="code-line line-number" line="8"><span class="token comment"># --> squash 的意思是这个 commit 会被合并到前一个commit</span>
|
||
</span><span class="code-line line-number" line="9">
|
||
</span><span class="code-line line-number" line="10"><span class="token comment"># 我们将 需要保留的 这个 commit 前方的命令改成 squash 或 s,然后输入:wq以保存并退出</span>
|
||
</span><span class="code-line line-number" line="11"><span class="token comment"># 这是我们会看到 commit message 的编辑界面</span>
|
||
</span><span class="code-line line-number" line="12">
|
||
</span><span class="code-line line-number" line="13"><span class="token comment"># 其中, 非注释部分就是两次的 commit message, 你要做的就是将这两个修改成新的 commit message。</span>
|
||
</span><span class="code-line line-number" line="14"><span class="token comment"># </span>
|
||
</span><span class="code-line line-number" line="15"><span class="token comment"># 输入wq保存并推出, 再次输入git log查看 commit 历史信息,你会发现这两个 commit 已经合并了。</span>
|
||
</span><span class="code-line line-number" line="16"><span class="token comment"># 将修改强制推送到前端</span>
|
||
</span><span class="code-line line-number" line="17"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master
|
||
</span></code><div onclick="copied(this)" data-code="# 这个命令,将最近4个commit合并为1个,HEAD代表当前版本。
|
||
# 将进入VIM界面,你可以修改提交信息。
|
||
git rebase -i HEAD~4
|
||
# 可以看到其中分为两个部分,上方未注释的部分是填写要执行的指令,
|
||
# 而下方注释的部分则是指令的提示说明。指令部分中由前方的命令名称、commit hash 和 commit message 组成
|
||
# 当前我们只要知道 pick 和 squash 这两个命令即可。
|
||
# --> pick 的意思是要会执行这个 commit
|
||
# --> squash 的意思是这个 commit 会被合并到前一个commit
|
||
|
||
# 我们将 需要保留的 这个 commit 前方的命令改成 squash 或 s,然后输入:wq以保存并退出
|
||
# 这是我们会看到 commit message 的编辑界面
|
||
|
||
# 其中, 非注释部分就是两次的 commit message, 你要做的就是将这两个修改成新的 commit message。
|
||
#
|
||
# 输入wq保存并推出, 再次输入git log查看 commit 历史信息,你会发现这两个 commit 已经合并了。
|
||
# 将修改强制推送到前端
|
||
git push -f origin master
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="修改远程commit记录"><a class="anchor" aria-hidden="true" tabindex="-1" href="#修改远程commit记录"><span class="octicon octicon-link"></span></a>修改远程Commit记录</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> commit <span class="token parameter variable">--amend</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># amend只能修改没有提交到线上的,最后一次commit记录</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> rebase <span class="token parameter variable">-i</span> HEAD~3
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># 表示要修改当前版本的倒数第三次状态</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># 将要更改的记录行首单词 pick 改为 edit</span>
|
||
</span><span class="code-line line-number" line="6">pick 96dc3f9 doc: Update quick-start.md
|
||
</span><span class="code-line line-number" line="7">pick f1cce8a test<span class="token punctuation">(</span>Transition<span class="token punctuation">)</span>:Add transition <span class="token builtin class-name">test</span> <span class="token punctuation">(</span><span class="token comment">#47)</span>
|
||
</span><span class="code-line line-number" line="8">pick <span class="token number">6293516</span> feat<span class="token punctuation">(</span>Divider<span class="token punctuation">)</span>: Add Divider component.
|
||
</span><span class="code-line line-number" line="9"><span class="token comment"># Rebase eeb03a4..6293516 onto eeb03a4 (3 commands)</span>
|
||
</span><span class="code-line line-number" line="10"><span class="token comment">#</span>
|
||
</span><span class="code-line line-number" line="11"><span class="token comment"># Commands:</span>
|
||
</span><span class="code-line line-number" line="12"><span class="token comment"># p, pick = use commit</span>
|
||
</span><span class="code-line line-number" line="13"><span class="token comment"># r, reword = use commit, but edit the commit message</span>
|
||
</span><span class="code-line line-number" line="14"><span class="token comment"># e, edit = use commit, but stop for amending</span>
|
||
</span><span class="code-line line-number" line="15"><span class="token comment"># s, squash = use commit, but meld into previous commit</span>
|
||
</span><span class="code-line line-number" line="16"><span class="token comment"># f, fixup = like "squash", but discard this commit's log message</span>
|
||
</span><span class="code-line line-number" line="17"><span class="token comment"># x, exec = run command (the rest of the line) using shell</span>
|
||
</span><span class="code-line line-number" line="18"><span class="token comment"># d, drop = remove commit</span>
|
||
</span></code><div onclick="copied(this)" data-code="git commit --amend
|
||
# amend只能修改没有提交到线上的,最后一次commit记录
|
||
git rebase -i HEAD~3
|
||
# 表示要修改当前版本的倒数第三次状态
|
||
# 将要更改的记录行首单词 pick 改为 edit
|
||
pick 96dc3f9 doc: Update quick-start.md
|
||
pick f1cce8a test(Transition):Add transition test (#47)
|
||
pick 6293516 feat(Divider): Add Divider component.
|
||
# Rebase eeb03a4..6293516 onto eeb03a4 (3 commands)
|
||
#
|
||
# Commands:
|
||
# p, pick = use commit
|
||
# r, reword = use commit, but edit the commit message
|
||
# e, edit = use commit, but stop for amending
|
||
# s, squash = use commit, but meld into previous commit
|
||
# f, fixup = like "squash", but discard this commit's log message
|
||
# x, exec = run command (the rest of the line) using shell
|
||
# d, drop = remove commit
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>保存并退出,会弹出下面提示</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment"># You can amend the commit now, with</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># git commit --amend</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># Once you are satisfied with your changes, run</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token comment"># git rebase --continue</span>
|
||
</span><span class="code-line line-number" line="8">
|
||
</span><span class="code-line line-number" line="9"><span class="token comment"># 通过这条命令进入编辑页面更改commit,保存退出</span>
|
||
</span><span class="code-line line-number" line="10"><span class="token function">git</span> commit <span class="token parameter variable">--amend</span>
|
||
</span><span class="code-line line-number" line="11"><span class="token comment"># 保存退出确认修改,继续执行 rebase, </span>
|
||
</span><span class="code-line line-number" line="12"><span class="token function">git</span> rebase <span class="token parameter variable">--continue</span>
|
||
</span><span class="code-line line-number" line="13"><span class="token comment"># 如果修改多条记录反复执行上面两条命令直到完成所有修改</span>
|
||
</span><span class="code-line line-number" line="14">
|
||
</span><span class="code-line line-number" line="15"><span class="token comment"># 最后,确保别人没有提交进行push,最好不要加 -f 强制推送</span>
|
||
</span><span class="code-line line-number" line="16"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master
|
||
</span></code><div onclick="copied(this)" data-code="# You can amend the commit now, with
|
||
#
|
||
# git commit --amend
|
||
#
|
||
# Once you are satisfied with your changes, run
|
||
#
|
||
# git rebase --continue
|
||
|
||
# 通过这条命令进入编辑页面更改commit,保存退出
|
||
git commit --amend
|
||
# 保存退出确认修改,继续执行 rebase,
|
||
git rebase --continue
|
||
# 如果修改多条记录反复执行上面两条命令直到完成所有修改
|
||
|
||
# 最后,确保别人没有提交进行push,最好不要加 -f 强制推送
|
||
git push -f origin master
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="添加忽略文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#添加忽略文件"><span class="octicon octicon-link"></span></a>添加忽略文件</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token builtin class-name">echo</span> node_modules/ <span class="token operator">>></span> .gitignore
|
||
</span></code><div onclick="copied(this)" data-code="echo node_modules/ >> .gitignore
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="利用commit关闭一个issue"><a class="anchor" aria-hidden="true" tabindex="-1" href="#利用commit关闭一个issue"><span class="octicon octicon-link"></span></a>利用commit关闭一个issue</h3>
|
||
<p>这个功能在Github上可以玩儿,Gitlab上特别老的版本不能玩儿哦,那么如何跟随着commit关闭一个issue呢? 在confirm merge的时候可以使用一下命令来关闭相关issue:</p>
|
||
<p><code>fixes #xxx</code>、 <code>fixed #xxx</code>、 <code>fix #xxx</code>、 <code>closes #xxx</code>、 <code>close #xxx</code>、 <code>closed #xxx</code>、</p>
|
||
<h3 id="同步fork的上游仓库"><a class="anchor" aria-hidden="true" tabindex="-1" href="#同步fork的上游仓库"><span class="octicon octicon-link"></span></a>同步fork的上游仓库</h3>
|
||
<p><a href="https://help.github.com/articles/syncing-a-fork/">Github教程同步fork教程</a>,<a href="http://www.miss77.net/549.html">在Github上同步一个分支(fork)</a></p>
|
||
<p><strong>设置添加多个远程仓库地址。</strong></p>
|
||
<p>在同步之前,需要创建一个远程点指向上游仓库(repo).如果你已经派生了一个原始仓库,可以按照如下方法做。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">$ <span class="token function">git</span> remote <span class="token parameter variable">-v</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># List the current remotes (列出当前远程仓库)</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># origin https://github.com/user/repo.git (fetch)</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># origin https://github.com/user/repo.git (push)</span>
|
||
</span><span class="code-line line-number" line="5">$ <span class="token function">git</span> remote <span class="token function">add</span> upstream https://github.com/otheruser/repo.git
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># Set a new remote (设置一个新的远程仓库)</span>
|
||
</span><span class="code-line line-number" line="7">$ <span class="token function">git</span> remote <span class="token parameter variable">-v</span>
|
||
</span><span class="code-line line-number" line="8"><span class="token comment"># Verify new remote (验证新的原唱仓库)</span>
|
||
</span><span class="code-line line-number" line="9"><span class="token comment"># origin https://github.com/user/repo.git (fetch)</span>
|
||
</span><span class="code-line line-number" line="10"><span class="token comment"># origin https://github.com/user/repo.git (push)</span>
|
||
</span><span class="code-line line-number" line="11"><span class="token comment"># upstream https://github.com/otheruser/repo.git (fetch)</span>
|
||
</span><span class="code-line line-number" line="12"><span class="token comment"># upstream https://github.com/otheruser/repo.git (push)</span>
|
||
</span></code><div onclick="copied(this)" data-code="$ git remote -v
|
||
# List the current remotes (列出当前远程仓库)
|
||
# origin https://github.com/user/repo.git (fetch)
|
||
# origin https://github.com/user/repo.git (push)
|
||
$ git remote add upstream https://github.com/otheruser/repo.git
|
||
# Set a new remote (设置一个新的远程仓库)
|
||
$ git remote -v
|
||
# Verify new remote (验证新的原唱仓库)
|
||
# origin https://github.com/user/repo.git (fetch)
|
||
# origin https://github.com/user/repo.git (push)
|
||
# upstream https://github.com/otheruser/repo.git (fetch)
|
||
# upstream https://github.com/otheruser/repo.git (push)
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>同步更新仓库内容</strong></p>
|
||
<p>同步上游仓库到你的仓库需要执行两步:首先你需要从远程拉去,之后你需要合并你希望的分支到你的本地副本分支。从上游的存储库中提取分支以及各自的提交内容。 <code>master</code> 将被存储在本地分支机构 <code>upstream/master</code></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> fetch upstream
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># remote: Counting objects: 75, done.</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># remote: Compressing objects: 100% (53/53), done.</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># remote: Total 62 (delta 27), reused 44 (delta 9)</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># Unpacking objects: 100% (62/62), done.</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY</span>
|
||
</span><span class="code-line line-number" line="7"><span class="token comment"># * [new branch] master -> upstream/master</span>
|
||
</span></code><div onclick="copied(this)" data-code="git fetch upstream
|
||
# remote: Counting objects: 75, done.
|
||
# remote: Compressing objects: 100% (53/53), done.
|
||
# remote: Total 62 (delta 27), reused 44 (delta 9)
|
||
# Unpacking objects: 100% (62/62), done.
|
||
# From https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY
|
||
# * [new branch] master -> upstream/master
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>检查你的 fork's 本地 <code>master</code> 分支</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> checkout master
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># Switched to branch 'master'</span>
|
||
</span></code><div onclick="copied(this)" data-code="git checkout master
|
||
# Switched to branch 'master'
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>合并来自 <code>upstream/master</code> 的更改到本地 master 分支上。 这使你的前 fork's <code>master</code> 分支与上游资源库同步,而不会丢失你本地修改。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> merge upstream/master
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># Updating a422352..5fdff0f</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># Fast-forward</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token comment"># README | 9 -------</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token comment"># README.md | 7 ++++++</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token comment"># 2 files changed, 7 insertions(+), 9 deletions(-)</span>
|
||
</span><span class="code-line line-number" line="7"><span class="token comment"># delete mode 100644 README</span>
|
||
</span><span class="code-line line-number" line="8"><span class="token comment"># create mode 100644 README.md</span>
|
||
</span></code><div onclick="copied(this)" data-code="git merge upstream/master
|
||
# Updating a422352..5fdff0f
|
||
# Fast-forward
|
||
# README | 9 -------
|
||
# README.md | 7 ++++++
|
||
# 2 files changed, 7 insertions(+), 9 deletions(-)
|
||
# delete mode 100644 README
|
||
# create mode 100644 README.md
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="批量修改历史commit中的名字和邮箱"><a class="anchor" aria-hidden="true" tabindex="-1" href="#批量修改历史commit中的名字和邮箱"><span class="octicon octicon-link"></span></a>批量修改历史commit中的名字和邮箱</h3>
|
||
<p><strong>1.克隆仓库</strong></p>
|
||
<p>注意参数,这个不是普通的clone,clone下来的仓库并不能参与开发</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone <span class="token parameter variable">--bare</span> https://github.com/user/repo.git
|
||
</span><span class="code-line line-number" line="2"><span class="token builtin class-name">cd</span> repo.git
|
||
</span></code><div onclick="copied(this)" data-code="git clone --bare https://github.com/user/repo.git
|
||
cd repo.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>2.命令行中运行代码</strong></p>
|
||
<p>OLD_EMAIL原来的邮箱<br>CORRECT_NAME更正的名字<br>CORRECT_EMAIL更正的邮箱</p>
|
||
<p>将下面代码复制放到命令行中执行</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> filter-branch <span class="token parameter variable">-f</span> --env-filter <span class="token string">'
|
||
</span></span><span class="code-line line-number" line="2"><span class="token string">OLD_EMAIL="wowohoo@qq.com"
|
||
</span></span><span class="code-line line-number" line="3"><span class="token string">CORRECT_NAME="小弟调调"
|
||
</span></span><span class="code-line line-number" line="4"><span class="token string">CORRECT_EMAIL="更正的邮箱@qq.com"
|
||
</span></span><span class="code-line line-number" line="5"><span class="token string">if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
|
||
</span></span><span class="code-line line-number" line="6"><span class="token string">then
|
||
</span></span><span class="code-line line-number" line="7"><span class="token string"> export GIT_COMMITTER_NAME="$CORRECT_NAME"
|
||
</span></span><span class="code-line line-number" line="8"><span class="token string"> export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
|
||
</span></span><span class="code-line line-number" line="9"><span class="token string">fi
|
||
</span></span><span class="code-line line-number" line="10"><span class="token string">if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
|
||
</span></span><span class="code-line line-number" line="11"><span class="token string">then
|
||
</span></span><span class="code-line line-number" line="12"><span class="token string"> export GIT_AUTHOR_NAME="$CORRECT_NAME"
|
||
</span></span><span class="code-line line-number" line="13"><span class="token string"> export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
|
||
</span></span><span class="code-line line-number" line="14"><span class="token string">fi
|
||
</span></span><span class="code-line line-number" line="15"><span class="token string">'</span> --tag-name-filter <span class="token function">cat</span> -- <span class="token parameter variable">--branches</span> <span class="token parameter variable">--tags</span>
|
||
</span></code><div onclick="copied(this)" data-code="git filter-branch -f --env-filter '
|
||
OLD_EMAIL="wowohoo@qq.com"
|
||
CORRECT_NAME="小弟调调"
|
||
CORRECT_EMAIL="更正的邮箱@qq.com"
|
||
if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
|
||
then
|
||
export GIT_COMMITTER_NAME="$CORRECT_NAME"
|
||
export GIT_COMMITTER_EMAIL="$CORRECT_EMAIL"
|
||
fi
|
||
if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
|
||
then
|
||
export GIT_AUTHOR_NAME="$CORRECT_NAME"
|
||
export GIT_AUTHOR_EMAIL="$CORRECT_EMAIL"
|
||
fi
|
||
' --tag-name-filter cat -- --branches --tags
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>执行过程</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">Rewrite 160d4df2689ff6df3820563bfd13b5f1fb9ba832 <span class="token punctuation">(</span><span class="token number">479</span>/508<span class="token punctuation">)</span> <span class="token punctuation">(</span><span class="token number">16</span> seconds passed, remaining <span class="token number">0</span> predicted<span class="token punctuation">)</span>
|
||
</span><span class="code-line line-number" line="2">Ref <span class="token string">'refs/heads/dev'</span> was rewritten
|
||
</span><span class="code-line line-number" line="3">Ref <span class="token string">'refs/heads/master'</span> was rewritten
|
||
</span></code><div onclick="copied(this)" data-code="Rewrite 160d4df2689ff6df3820563bfd13b5f1fb9ba832 (479/508) (16 seconds passed, remaining 0 predicted)
|
||
Ref 'refs/heads/dev' was rewritten
|
||
Ref 'refs/heads/master' was rewritten
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>3.同步到远程仓库</strong></p>
|
||
<p>同步到push远程git仓库</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push <span class="token parameter variable">--force</span> <span class="token parameter variable">--tags</span> origin <span class="token string">'refs/heads/*'</span>
|
||
</span></code><div onclick="copied(this)" data-code="git push --force --tags origin 'refs/heads/*'
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>我还遇到了如下面错误,lab默认给master分支加了保护,不允许强制覆盖。<code>Project(项目)</code>-><code>Setting</code>-><code>Repository</code> 菜单下面的<code>Protected branches</code>把master的保护去掉就可以了。修改完之后,建议把master的保护再加回来,毕竟强推不是件好事。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">remote: GitLab: You are not allowed to force push code to a protected branch on this project.
|
||
</span></code><div onclick="copied(this)" data-code="remote: GitLab: You are not allowed to force push code to a protected branch on this project.
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>当上面的push 不上去的时候,先 <code>git pull</code> 确保最新代码</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> pull --allow-unrelated-histories
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># 或者指定分枝</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> pull origin master --allow-unrelated-histories
|
||
</span></code><div onclick="copied(this)" data-code="git pull --allow-unrelated-histories
|
||
# 或者指定分枝
|
||
git pull origin master --allow-unrelated-histories
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="查看某个文件历史"><a class="anchor" aria-hidden="true" tabindex="-1" href="#查看某个文件历史"><span class="octicon octicon-link"></span></a>查看某个文件历史</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>oneline 文件名 <span class="token comment"># 列出文件的所有改动历史 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> show c178bf49 <span class="token comment"># 某次的改动的修改记录 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> log <span class="token parameter variable">-p</span> c178bf49 <span class="token comment"># 某次的改动的修改记录 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> blame 文件名 <span class="token comment"># 显示文件的每一行是在那个版本最后修改。 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> whatchanged 文件名 <span class="token comment"># 显示某个文件的每个版本提交信息:提交日期,提交人员,版本号,提交备注(没有修改细节) </span>
|
||
</span></code><div onclick="copied(this)" data-code="git log --pretty=oneline 文件名 # 列出文件的所有改动历史
|
||
git show c178bf49 # 某次的改动的修改记录
|
||
git log -p c178bf49 # 某次的改动的修改记录
|
||
git blame 文件名 # 显示文件的每一行是在那个版本最后修改。
|
||
git whatchanged 文件名 # 显示某个文件的每个版本提交信息:提交日期,提交人员,版本号,提交备注(没有修改细节)
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="打造自己的git命令"><a class="anchor" aria-hidden="true" tabindex="-1" href="#打造自己的git命令"><span class="octicon octicon-link"></span></a>打造自己的git命令</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.st status
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.br branch
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.co checkout
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> config <span class="token parameter variable">--global</span> alias.ci commit
|
||
</span></code><div onclick="copied(this)" data-code="git config --global alias.st status
|
||
git config --global alias.br branch
|
||
git config --global alias.co checkout
|
||
git config --global alias.ci commit
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>配置好后再输入git命令的时候就不用再输入一大段了,例如我们要查看状态,只需:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> st
|
||
</span></code><div onclick="copied(this)" data-code="git st
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="中文乱码的解决方案"><a class="anchor" aria-hidden="true" tabindex="-1" href="#中文乱码的解决方案"><span class="octicon octicon-link"></span></a>中文乱码的解决方案</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config <span class="token parameter variable">--global</span> core.quotepath <span class="token boolean">false</span>
|
||
</span></code><div onclick="copied(this)" data-code="git config --global core.quotepath false
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="新建仓库"><a class="anchor" aria-hidden="true" tabindex="-1" href="#新建仓库"><span class="octicon octicon-link"></span></a>新建仓库</h2>
|
||
<h3 id="init"><a class="anchor" aria-hidden="true" tabindex="-1" href="#init"><span class="octicon octicon-link"></span></a>init</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> init <span class="token comment"># 初始化</span>
|
||
</span></code><div onclick="copied(this)" data-code="git init # 初始化
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="status"><a class="anchor" aria-hidden="true" tabindex="-1" href="#status"><span class="octicon octicon-link"></span></a>status</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> status <span class="token comment"># 获取状态</span>
|
||
</span></code><div onclick="copied(this)" data-code="git status # 获取状态
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="add"><a class="anchor" aria-hidden="true" tabindex="-1" href="#add"><span class="octicon octicon-link"></span></a>add</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token function">add</span> <span class="token function">file</span> <span class="token comment"># .或*代表全部添加</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">--cached</span> <span class="token operator"><</span>added_file_to_undo<span class="token operator">></span> <span class="token comment"># 在commit之前撤销git add操作</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> reset <span class="token function">head</span> <span class="token comment"># 好像比上面`git rm --cached`更方便</span>
|
||
</span></code><div onclick="copied(this)" data-code="git add file # .或*代表全部添加
|
||
git rm --cached <added_file_to_undo> # 在commit之前撤销git add操作
|
||
git reset head # 好像比上面`git rm --cached`更方便
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="commit"><a class="anchor" aria-hidden="true" tabindex="-1" href="#commit"><span class="octicon octicon-link"></span></a>commit</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">"message"</span> <span class="token comment"># 此处注意乱码</span>
|
||
</span></code><div onclick="copied(this)" data-code="git commit -m "message" # 此处注意乱码
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="remote"><a class="anchor" aria-hidden="true" tabindex="-1" href="#remote"><span class="octicon octicon-link"></span></a>remote</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote <span class="token function">add</span> origin git@github.com:JSLite/test.git <span class="token comment"># 添加源 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git remote add origin git@github.com:JSLite/test.git # 添加源
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="push"><a class="anchor" aria-hidden="true" tabindex="-1" href="#push"><span class="octicon octicon-link"></span></a>push</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push <span class="token parameter variable">-u</span> origin master <span class="token comment"># push同事设置默认跟踪分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push origin master
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> push <span class="token parameter variable">-f</span> origin master <span class="token comment"># 强制推送文件,缩写 -f(全写--force)</span>
|
||
</span></code><div onclick="copied(this)" data-code="git push -u origin master # push同事设置默认跟踪分支
|
||
git push origin master
|
||
git push -f origin master # 强制推送文件,缩写 -f(全写--force)
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="clone"><a class="anchor" aria-hidden="true" tabindex="-1" href="#clone"><span class="octicon octicon-link"></span></a>clone</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone git://github.com/JSLite/JSLite.js.git
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> clone git://github.com/JSLite/JSLite.js.git mypro <span class="token comment"># 克隆到自定义文件夹 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> clone <span class="token punctuation">[</span>user@<span class="token punctuation">]</span>example.com:path/to/repo.git/ <span class="token comment"># SSH协议还有另一种写法。 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git clone git://github.com/JSLite/JSLite.js.git
|
||
git clone git://github.com/JSLite/JSLite.js.git mypro # 克隆到自定义文件夹
|
||
git clone [user@]example.com:path/to/repo.git/ # SSH协议还有另一种写法。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>git clone支持多种协议,除了HTTP(s)以外,还支持SSH、Git、本地文件协议等,下面是一些例子。<code>git clone <版本库的网址> <本地目录名></code></p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone http<span class="token punctuation">[</span>s<span class="token punctuation">]</span>://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> clone ssh://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> clone git://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> clone /opt/git/project.git
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> clone file:///opt/git/project.git
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> clone ftp<span class="token punctuation">[</span>s<span class="token punctuation">]</span>://example.com/path/to/repo.git/
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> clone rsync://example.com/path/to/repo.git/
|
||
</span></code><div onclick="copied(this)" data-code="git clone http[s]://example.com/path/to/repo.git/
|
||
git clone ssh://example.com/path/to/repo.git/
|
||
git clone git://example.com/path/to/repo.git/
|
||
git clone /opt/git/project.git
|
||
git clone file:///opt/git/project.git
|
||
git clone ftp[s]://example.com/path/to/repo.git/
|
||
git clone rsync://example.com/path/to/repo.git/
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="本地"><a class="anchor" aria-hidden="true" tabindex="-1" href="#本地"><span class="octicon octicon-link"></span></a>本地</h2>
|
||
<h3 id="help"><a class="anchor" aria-hidden="true" tabindex="-1" href="#help"><span class="octicon octicon-link"></span></a>help</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token builtin class-name">help</span> config <span class="token comment"># 获取帮助信息 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git help config # 获取帮助信息
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="add-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#add-1"><span class="octicon octicon-link"></span></a>add</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token function">add</span> * <span class="token comment"># 跟踪新文件 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> <span class="token function">add</span> <span class="token parameter variable">-u</span> <span class="token punctuation">[</span>path<span class="token punctuation">]</span> <span class="token comment"># 添加[指定路径下]已跟踪文件 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git add * # 跟踪新文件
|
||
git add -u [path] # 添加[指定路径下]已跟踪文件
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="rm"><a class="anchor" aria-hidden="true" tabindex="-1" href="#rm"><span class="octicon octicon-link"></span></a>rm</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">rm</span> *<span class="token operator">&</span><span class="token function">git</span> <span class="token function">rm</span> * <span class="token comment"># 移除文件 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">-f</span> * <span class="token comment"># 移除文件 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">--cached</span> * <span class="token comment"># 取消跟踪 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> <span class="token function">mv</span> file_from file_to <span class="token comment"># 重命名跟踪文件 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> log <span class="token comment"># 查看提交记录 </span>
|
||
</span></code><div onclick="copied(this)" data-code="rm *&git rm * # 移除文件
|
||
git rm -f * # 移除文件
|
||
git rm --cached * # 取消跟踪
|
||
git mv file_from file_to # 重命名跟踪文件
|
||
git log # 查看提交记录
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="commit-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#commit-1"><span class="octicon octicon-link"></span></a>commit</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> commit <span class="token comment">#提交更新 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">'message'</span> <span class="token comment">#提交说明 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> commit <span class="token parameter variable">-a</span> <span class="token comment">#跳过使用暂存区域,把所有已经跟踪过的文件暂存起来一并提交 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> commit <span class="token parameter variable">--amend</span> <span class="token comment">#修改最后一次提交 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> commit log <span class="token comment">#查看所有提交,包括没有push的commit </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">"#133"</span> <span class="token comment">#关联issue 任意位置带上# 符号加上issue号码 </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">"fix #133"</span> commit关闭issue
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> commit <span class="token parameter variable">-m</span> <span class="token string">'概要描述'</span><span class="token string">$'<span class="token entity" title="\n">\n</span><span class="token entity" title="\n">\n</span>'</span>'1.详细描述<span class="token string">'$'</span><span class="token punctuation">\</span>n<span class="token string">''</span><span class="token number">2</span>.详细描述' <span class="token comment">#提交简要描述和详细描述 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git commit #提交更新
|
||
git commit -m 'message' #提交说明
|
||
git commit -a #跳过使用暂存区域,把所有已经跟踪过的文件暂存起来一并提交
|
||
git commit --amend #修改最后一次提交
|
||
git commit log #查看所有提交,包括没有push的commit
|
||
git commit -m "#133" #关联issue 任意位置带上# 符号加上issue号码
|
||
git commit -m "fix #133" commit关闭issue
|
||
git commit -m '概要描述'$'\n\n''1.详细描述'$'\n''2.详细描述' #提交简要描述和详细描述
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="reset"><a class="anchor" aria-hidden="true" tabindex="-1" href="#reset"><span class="octicon octicon-link"></span></a>reset</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> reset HEAD * <span class="token comment"># 取消已经暂存的文件 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> reset <span class="token parameter variable">--mixed</span> HEAD * <span class="token comment"># 同上 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> reset <span class="token parameter variable">--soft</span> HEAD * <span class="token comment"># 重置到指定状态,不会修改索引区和工作树 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> reset <span class="token parameter variable">--hard</span> HEAD * <span class="token comment"># 重置到指定状态,会修改索引区和工作树 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> reset -- files * <span class="token comment"># 重置index区文件 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git reset HEAD * # 取消已经暂存的文件
|
||
git reset --mixed HEAD * # 同上
|
||
git reset --soft HEAD * # 重置到指定状态,不会修改索引区和工作树
|
||
git reset --hard HEAD * # 重置到指定状态,会修改索引区和工作树
|
||
git reset -- files * # 重置index区文件
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="revert"><a class="anchor" aria-hidden="true" tabindex="-1" href="#revert"><span class="octicon octicon-link"></span></a>revert</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> revert HEAD <span class="token comment"># 撤销前一次操作 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> revert HEAD~ <span class="token comment"># 撤销前前一次操作 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> revert commit <span class="token comment"># 撤销指定操作 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git revert HEAD # 撤销前一次操作
|
||
git revert HEAD~ # 撤销前前一次操作
|
||
git revert commit # 撤销指定操作
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="checkout"><a class="anchor" aria-hidden="true" tabindex="-1" href="#checkout"><span class="octicon octicon-link"></span></a>checkout</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> checkout -- <span class="token function">file</span> <span class="token comment"># 取消对文件的修改(从暂存区——覆盖worktree file) </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> checkout branch<span class="token operator">|</span>tag<span class="token operator">|</span>commit -- file_name <span class="token comment"># 从仓库取出file覆盖当前分支 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> checkout HEAD~1 <span class="token punctuation">[</span>文件<span class="token punctuation">]</span> <span class="token comment"># 将会更新 working directory 去匹配某次 commit </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> checkout -- <span class="token builtin class-name">.</span> <span class="token comment"># 从暂存区取出文件覆盖工作区 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> gh-pages 0c304c9 <span class="token comment"># 这个表示 从当前分支 commit 哈希值为 0c304c9 的节点,分一个新的分支gh-pages出来,并切换到 gh-pages </span>
|
||
</span></code><div onclick="copied(this)" data-code="git checkout -- file # 取消对文件的修改(从暂存区——覆盖worktree file)
|
||
git checkout branch|tag|commit -- file_name # 从仓库取出file覆盖当前分支
|
||
git checkout HEAD~1 [文件] # 将会更新 working directory 去匹配某次 commit
|
||
git checkout -- . # 从暂存区取出文件覆盖工作区
|
||
git checkout -b gh-pages 0c304c9 # 这个表示 从当前分支 commit 哈希值为 0c304c9 的节点,分一个新的分支gh-pages出来,并切换到 gh-pages
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="diff"><a class="anchor" aria-hidden="true" tabindex="-1" href="#diff"><span class="octicon octicon-link"></span></a>diff</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token function">diff</span> <span class="token function">file</span> <span class="token comment"># 查看指定文件的差异 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> <span class="token function">diff</span> <span class="token parameter variable">--stat</span> <span class="token comment"># 查看简单的diff结果 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> <span class="token function">diff</span> <span class="token comment"># 比较Worktree和Index之间的差异 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> <span class="token function">diff</span> <span class="token parameter variable">--cached</span> <span class="token comment"># 比较Index和HEAD之间的差异 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> <span class="token function">diff</span> HEAD <span class="token comment"># 比较Worktree和HEAD之间的差异 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> <span class="token function">diff</span> branch <span class="token comment"># 比较Worktree和branch之间的差异 </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> <span class="token function">diff</span> branch1 branch2 <span class="token comment"># 比较两次分支之间的差异 </span>
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> <span class="token function">diff</span> commit commit <span class="token comment"># 比较两次提交之间的差异 </span>
|
||
</span><span class="code-line line-number" line="9"><span class="token function">git</span> <span class="token function">diff</span> master<span class="token punctuation">..</span>test <span class="token comment"># 上面这条命令只显示两个分支间的差异 </span>
|
||
</span><span class="code-line line-number" line="10"><span class="token function">git</span> <span class="token function">diff</span> master<span class="token punctuation">..</span>.test <span class="token comment"># 你想找出‘master’,‘test’的共有 父分支和'test'分支之间的差异,你用3个‘.'来取代前面的两个'.' </span>
|
||
</span></code><div onclick="copied(this)" data-code="git diff file # 查看指定文件的差异
|
||
git diff --stat # 查看简单的diff结果
|
||
git diff # 比较Worktree和Index之间的差异
|
||
git diff --cached # 比较Index和HEAD之间的差异
|
||
git diff HEAD # 比较Worktree和HEAD之间的差异
|
||
git diff branch # 比较Worktree和branch之间的差异
|
||
git diff branch1 branch2 # 比较两次分支之间的差异
|
||
git diff commit commit # 比较两次提交之间的差异
|
||
git diff master..test # 上面这条命令只显示两个分支间的差异
|
||
git diff master...test # 你想找出‘master’,‘test’的共有 父分支和'test'分支之间的差异,你用3个‘.'来取代前面的两个'.'
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="stash"><a class="anchor" aria-hidden="true" tabindex="-1" href="#stash"><span class="octicon octicon-link"></span></a>stash</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> stash <span class="token comment"># 将工作区现场(已跟踪文件)储藏起来,等以后恢复后继续工作。 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> stash list <span class="token comment"># 查看保存的工作现场 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> stash apply <span class="token comment"># 恢复工作现场 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> stash drop <span class="token comment"># 删除stash内容 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> stash pop <span class="token comment"># 恢复的同时直接删除stash内容 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> stash apply stash@<span class="token punctuation">{</span><span class="token number">0</span><span class="token punctuation">}</span> <span class="token comment"># 恢复指定的工作现场,当你保存了不只一份工作现场时。 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git stash # 将工作区现场(已跟踪文件)储藏起来,等以后恢复后继续工作。
|
||
git stash list # 查看保存的工作现场
|
||
git stash apply # 恢复工作现场
|
||
git stash drop # 删除stash内容
|
||
git stash pop # 恢复的同时直接删除stash内容
|
||
git stash apply stash@{0} # 恢复指定的工作现场,当你保存了不只一份工作现场时。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="merge"><a class="anchor" aria-hidden="true" tabindex="-1" href="#merge"><span class="octicon octicon-link"></span></a>merge</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> merge <span class="token parameter variable">--squash</span> <span class="token builtin class-name">test</span> <span class="token comment"># 合并压缩,将test上的commit压缩为一条 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git merge --squash test # 合并压缩,将test上的commit压缩为一条
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="cherry-pick"><a class="anchor" aria-hidden="true" tabindex="-1" href="#cherry-pick"><span class="octicon octicon-link"></span></a>cherry-pick</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> cherry-pick commit <span class="token comment"># 拣选合并,将commit合并到当前分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> cherry-pick <span class="token parameter variable">-n</span> commit <span class="token comment"># 拣选多个提交,合并完后可以继续拣选下一个提交 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git cherry-pick commit # 拣选合并,将commit合并到当前分支
|
||
git cherry-pick -n commit # 拣选多个提交,合并完后可以继续拣选下一个提交
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="rebase"><a class="anchor" aria-hidden="true" tabindex="-1" href="#rebase"><span class="octicon octicon-link"></span></a>rebase</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> rebase master <span class="token comment"># 将master分之上超前的提交,变基到当前分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> rebase <span class="token parameter variable">--onto</span> master 169a6 <span class="token comment"># 限制回滚范围,rebase当前分支从169a6以后的提交 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> rebase <span class="token parameter variable">--interactive</span> <span class="token comment"># 交互模式,修改commit </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> rebase <span class="token parameter variable">--continue</span> <span class="token comment"># 处理完冲突继续合并 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> rebase <span class="token parameter variable">--skip</span> <span class="token comment"># 跳过 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> rebase <span class="token parameter variable">--abort</span> <span class="token comment"># 取消合并 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git rebase master # 将master分之上超前的提交,变基到当前分支
|
||
git rebase --onto master 169a6 # 限制回滚范围,rebase当前分支从169a6以后的提交
|
||
git rebase --interactive # 交互模式,修改commit
|
||
git rebase --continue # 处理完冲突继续合并
|
||
git rebase --skip # 跳过
|
||
git rebase --abort # 取消合并
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="分支branch"><a class="anchor" aria-hidden="true" tabindex="-1" href="#分支branch"><span class="octicon octicon-link"></span></a>分支branch</h2>
|
||
<h3 id="删除"><a class="anchor" aria-hidden="true" tabindex="-1" href="#删除"><span class="octicon octicon-link"></span></a>删除</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push origin :branchName <span class="token comment"># 删除远程分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push origin <span class="token parameter variable">--delete</span> new <span class="token comment"># 删除远程分支new </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> branch <span class="token parameter variable">-d</span> branchName <span class="token comment"># 删除本地分支,强制删除用-D </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> branch <span class="token parameter variable">-d</span> <span class="token builtin class-name">test</span> <span class="token comment"># 删除本地test分支 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> branch <span class="token parameter variable">-D</span> <span class="token builtin class-name">test</span> <span class="token comment"># 强制删除本地test分支 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> remote prune origin <span class="token comment"># 远程删除了,本地还能看到远程存在,这条命令删除远程不存在的分支</span>
|
||
</span></code><div onclick="copied(this)" data-code="git push origin :branchName # 删除远程分支
|
||
git push origin --delete new # 删除远程分支new
|
||
git branch -d branchName # 删除本地分支,强制删除用-D
|
||
git branch -d test # 删除本地test分支
|
||
git branch -D test # 强制删除本地test分支
|
||
git remote prune origin # 远程删除了,本地还能看到远程存在,这条命令删除远程不存在的分支
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="提交"><a class="anchor" aria-hidden="true" tabindex="-1" href="#提交"><span class="octicon octicon-link"></span></a>提交</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> push <span class="token parameter variable">-u</span> origin branchName <span class="token comment"># 提交分支到远程origin主机中 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git push -u origin branchName # 提交分支到远程origin主机中
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="拉取"><a class="anchor" aria-hidden="true" tabindex="-1" href="#拉取"><span class="octicon octicon-link"></span></a>拉取</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> fetch <span class="token parameter variable">-p</span> <span class="token comment"># 拉取远程分支时,自动清理 远程分支已删除,本地还存在的对应同名分支。</span>
|
||
</span></code><div onclick="copied(this)" data-code="git fetch -p # 拉取远程分支时,自动清理 远程分支已删除,本地还存在的对应同名分支。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="分支合并"><a class="anchor" aria-hidden="true" tabindex="-1" href="#分支合并"><span class="octicon octicon-link"></span></a>分支合并</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> merge branchName <span class="token comment"># 合并分支 - 将分支branchName和当前所在分支合并 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> merge origin/master <span class="token comment"># 在本地分支上合并远程分支。 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> rebase origin/master <span class="token comment"># 在本地分支上合并远程分支。 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> merge <span class="token builtin class-name">test</span> <span class="token comment"># 将test分支合并到当前分支 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git merge branchName # 合并分支 - 将分支branchName和当前所在分支合并
|
||
git merge origin/master # 在本地分支上合并远程分支。
|
||
git rebase origin/master # 在本地分支上合并远程分支。
|
||
git merge test # 将test分支合并到当前分支
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="重命名"><a class="anchor" aria-hidden="true" tabindex="-1" href="#重命名"><span class="octicon octicon-link"></span></a>重命名</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> branch <span class="token parameter variable">-m</span> old new <span class="token comment"># 重命名分支</span>
|
||
</span></code><div onclick="copied(this)" data-code="git branch -m old new # 重命名分支
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="查看"><a class="anchor" aria-hidden="true" tabindex="-1" href="#查看"><span class="octicon octicon-link"></span></a>查看</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> branch <span class="token comment"># 列出本地分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> branch <span class="token parameter variable">-r</span> <span class="token comment"># 列出远端分支 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> branch <span class="token parameter variable">-a</span> <span class="token comment"># 列出所有分支 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> branch <span class="token parameter variable">-v</span> <span class="token comment"># 查看各个分支最后一个提交对象的信息 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> branch <span class="token parameter variable">--merge</span> <span class="token comment"># 查看已经合并到当前分支的分支 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> branch --no-merge <span class="token comment"># 查看为合并到当前分支的分支 </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> remote show origin <span class="token comment"># 可以查看remote地址,远程分支</span>
|
||
</span></code><div onclick="copied(this)" data-code="git branch # 列出本地分支
|
||
git branch -r # 列出远端分支
|
||
git branch -a # 列出所有分支
|
||
git branch -v # 查看各个分支最后一个提交对象的信息
|
||
git branch --merge # 查看已经合并到当前分支的分支
|
||
git branch --no-merge # 查看为合并到当前分支的分支
|
||
git remote show origin # 可以查看remote地址,远程分支
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="新建"><a class="anchor" aria-hidden="true" tabindex="-1" href="#新建"><span class="octicon octicon-link"></span></a>新建</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> branch <span class="token builtin class-name">test</span> <span class="token comment"># 新建test分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> branch newBrach 3defc69 <span class="token comment"># 指定哈希3defc69,新建分支名字为newBrach</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> newBrach origin/master <span class="token comment"># 取回远程主机的更新以后,在它的基础上创建一个新的分支 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> newBrach 3defc69 <span class="token comment"># 以哈希值3defc69,新建 newBrach 分支,并切换到该分支</span>
|
||
</span></code><div onclick="copied(this)" data-code="git branch test # 新建test分支
|
||
git branch newBrach 3defc69 # 指定哈希3defc69,新建分支名字为newBrach
|
||
git checkout -b newBrach origin/master # 取回远程主机的更新以后,在它的基础上创建一个新的分支
|
||
git checkout -b newBrach 3defc69 # 以哈希值3defc69,新建 newBrach 分支,并切换到该分支
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="连接"><a class="anchor" aria-hidden="true" tabindex="-1" href="#连接"><span class="octicon octicon-link"></span></a>连接</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> branch --set-upstream dev origin/dev <span class="token comment"># 将本地dev分支与远程dev分支之间建立链接 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> branch --set-upstream master origin/next <span class="token comment"># 手动建立追踪关系 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git branch --set-upstream dev origin/dev # 将本地dev分支与远程dev分支之间建立链接
|
||
git branch --set-upstream master origin/next # 手动建立追踪关系
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="分支切换"><a class="anchor" aria-hidden="true" tabindex="-1" href="#分支切换"><span class="octicon octicon-link"></span></a>分支切换</h3>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> checkout <span class="token builtin class-name">test</span> <span class="token comment"># 切换到test分支 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> <span class="token builtin class-name">test</span> <span class="token comment"># 新建+切换到test分支 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> <span class="token builtin class-name">test</span> dev <span class="token comment"># 基于dev新建test分支,并切换 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git checkout test # 切换到test分支
|
||
git checkout -b test # 新建+切换到test分支
|
||
git checkout -b test dev # 基于dev新建test分支,并切换
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="远端"><a class="anchor" aria-hidden="true" tabindex="-1" href="#远端"><span class="octicon octicon-link"></span></a>远端</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> fetch <span class="token operator"><</span>远程主机名<span class="token operator">></span> <span class="token operator"><</span>分支名<span class="token operator">></span> <span class="token comment"># fetch取回所有分支(branch)的更新 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> fetch origin remotebranch<span class="token punctuation">[</span>:localbranch<span class="token punctuation">]</span> <span class="token comment"># 从远端拉去分支[到本地指定分支] </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> merge origin/branch <span class="token comment"># 合并远端上指定分支 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> pull origin remotebranch:localbranch <span class="token comment"># 拉去远端分支到本地分支 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> push origin branch <span class="token comment"># 将当前分支,推送到远端上指定分支 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> push origin localbranch:remotebranch <span class="token comment"># 推送本地指定分支,到远端上指定分支 </span>
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> push origin :remotebranch <span class="token comment"># 删除远端指定分支 </span>
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> checkout <span class="token parameter variable">-b</span> <span class="token punctuation">[</span>--track<span class="token punctuation">]</span> <span class="token builtin class-name">test</span> origin/dev <span class="token comment"># 基于远端dev分支,新建本地test分支[同时设置跟踪] </span>
|
||
</span></code><div onclick="copied(this)" data-code="git fetch <远程主机名> <分支名> # fetch取回所有分支(branch)的更新
|
||
git fetch origin remotebranch[:localbranch] # 从远端拉去分支[到本地指定分支]
|
||
git merge origin/branch # 合并远端上指定分支
|
||
git pull origin remotebranch:localbranch # 拉去远端分支到本地分支
|
||
git push origin branch # 将当前分支,推送到远端上指定分支
|
||
git push origin localbranch:remotebranch # 推送本地指定分支,到远端上指定分支
|
||
git push origin :remotebranch # 删除远端指定分支
|
||
git checkout -b [--track] test origin/dev # 基于远端dev分支,新建本地test分支[同时设置跟踪]
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="submodule"><a class="anchor" aria-hidden="true" tabindex="-1" href="#submodule"><span class="octicon octicon-link"></span></a>submodule</h2>
|
||
<p>克隆项目同时克隆submodule</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> clone https://github.com/jaywcjlove/handbook.git <span class="token parameter variable">--depth</span><span class="token operator">=</span><span class="token number">1</span> --recurse-submodules
|
||
</span></code><div onclick="copied(this)" data-code="git clone https://github.com/jaywcjlove/handbook.git --depth=1 --recurse-submodules
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>克隆项目,之后再手动克隆 submodule 子项目</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> submodule <span class="token function">add</span> <span class="token parameter variable">--force</span> <span class="token string">'仓库地址'</span> <span class="token string">'路径'</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token comment"># 其中,仓库地址是指子模块仓库地址,路径指将子模块放置在当前工程下的路径。</span>
|
||
</span><span class="code-line line-number" line="3"><span class="token comment"># 注意:路径不能以 / 结尾(会造成修改不生效)、不能是现有工程已有的目录(不能順利 Clone)</span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> submodule init <span class="token comment"># 初始化submodule</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> submodule update <span class="token comment"># 更新submodule(必须在根目录执行命令)</span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> submodule update <span class="token parameter variable">--init</span> <span class="token parameter variable">--recursive</span> <span class="token comment"># 下载的工程带有submodule</span>
|
||
</span></code><div onclick="copied(this)" data-code="git submodule add --force '仓库地址' '路径'
|
||
# 其中,仓库地址是指子模块仓库地址,路径指将子模块放置在当前工程下的路径。
|
||
# 注意:路径不能以 / 结尾(会造成修改不生效)、不能是现有工程已有的目录(不能順利 Clone)
|
||
git submodule init # 初始化submodule
|
||
git submodule update # 更新submodule(必须在根目录执行命令)
|
||
git submodule update --init --recursive # 下载的工程带有submodule
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>当使用<code>git clone</code>下来的工程中带有submodule时,初始的时候,submodule的内容并不会自动下载下来的,此时,只需执行如下命令:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> submodule foreach <span class="token function">git</span> pull <span class="token comment"># submodule 里有其他的 submodule 一次更新</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> submodule foreach <span class="token function">git</span> pull origin master <span class="token comment"># submodule更新</span>
|
||
</span><span class="code-line line-number" line="3">
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> submodule foreach <span class="token parameter variable">--recursive</span> <span class="token function">git</span> submodule init
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> submodule foreach <span class="token parameter variable">--recursive</span> <span class="token function">git</span> submodule update
|
||
</span></code><div onclick="copied(this)" data-code="git submodule foreach git pull # submodule 里有其他的 submodule 一次更新
|
||
git submodule foreach git pull origin master # submodule更新
|
||
|
||
git submodule foreach --recursive git submodule init
|
||
git submodule foreach --recursive git submodule update
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="删除文件"><a class="anchor" aria-hidden="true" tabindex="-1" href="#删除文件"><span class="octicon octicon-link"></span></a>删除文件</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token function">rm</span> <span class="token parameter variable">-rf</span> node_modules/
|
||
</span></code><div onclick="copied(this)" data-code="git rm -rf node_modules/
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="remote-1"><a class="anchor" aria-hidden="true" tabindex="-1" href="#remote-1"><span class="octicon octicon-link"></span></a>remote</h2>
|
||
<p>git是一个分布式代码管理工具,所以可以支持多个仓库,在git里,服务器上的仓库在本地称之为remote。个人开发时,多源用的可能不多,但多源其实非常有用。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> remote <span class="token function">add</span> origin1 git@github.com:yanhaijing/data.js.git
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> remote <span class="token comment"># 显示全部源 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> remote <span class="token parameter variable">-v</span> <span class="token comment"># 显示全部源+详细信息 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> remote <span class="token function">rename</span> origin1 origin2 <span class="token comment"># 重命名 </span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> remote <span class="token function">rm</span> origin <span class="token comment"># 删除 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> remote show origin <span class="token comment"># 查看指定源的全部信息 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git remote add origin1 git@github.com:yanhaijing/data.js.git
|
||
git remote # 显示全部源
|
||
git remote -v # 显示全部源+详细信息
|
||
git remote rename origin1 origin2 # 重命名
|
||
git remote rm origin # 删除
|
||
git remote show origin # 查看指定源的全部信息
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="标签tag"><a class="anchor" aria-hidden="true" tabindex="-1" href="#标签tag"><span class="octicon octicon-link"></span></a>标签tag</h2>
|
||
<p>当开发到一定阶段时,给程序打标签是非常棒的功能。</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> tag <span class="token parameter variable">-a</span> v0.1 <span class="token parameter variable">-m</span> <span class="token string">'my version 1.4'</span> <span class="token comment"># 新建带注释标签 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> push origin <span class="token parameter variable">--tags</span> <span class="token comment"># 一次性推送所有分支 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> push origin v1.5 <span class="token comment"># 推送单个tag到origin源上 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> tag <span class="token parameter variable">-v</span> v1.4.2.1 <span class="token comment"># 验证标签,验证已经签署的标签</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> show v1.5 <span class="token comment"># 看到对应的 GPG 签</span>
|
||
</span><span class="code-line line-number" line="6">
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> tag <span class="token comment"># 列出现有标签 </span>
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> tag v0gi.1 <span class="token comment"># 新建标签 </span>
|
||
</span><span class="code-line line-number" line="9"><span class="token function">git</span> checkout tagname <span class="token comment"># 切换到标签 </span>
|
||
</span><span class="code-line line-number" line="10"><span class="token function">git</span> tag <span class="token parameter variable">-d</span> v0.1 <span class="token comment"># 删除标签 </span>
|
||
</span><span class="code-line line-number" line="11"><span class="token function">git</span> push origin :refs/tags/v0.1 <span class="token comment"># 删除远程标签 </span>
|
||
</span><span class="code-line line-number" line="12"><span class="token function">git</span> pull <span class="token parameter variable">--all</span> <span class="token comment"># 获取远程所有内容包括tag </span>
|
||
</span><span class="code-line line-number" line="13"><span class="token function">git</span> --git-dir<span class="token operator">=</span><span class="token string">'<绝对地址>/.git'</span> describe <span class="token parameter variable">--tags</span> HEAD <span class="token comment"># 查看本地版本信息 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git tag -a v0.1 -m 'my version 1.4' # 新建带注释标签
|
||
git push origin --tags # 一次性推送所有分支
|
||
git push origin v1.5 # 推送单个tag到origin源上
|
||
git tag -v v1.4.2.1 # 验证标签,验证已经签署的标签
|
||
git show v1.5 # 看到对应的 GPG 签
|
||
|
||
git tag # 列出现有标签
|
||
git tag v0gi.1 # 新建标签
|
||
git checkout tagname # 切换到标签
|
||
git tag -d v0.1 # 删除标签
|
||
git push origin :refs/tags/v0.1 # 删除远程标签
|
||
git pull --all # 获取远程所有内容包括tag
|
||
git --git-dir='<绝对地址>/.git' describe --tags HEAD # 查看本地版本信息
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="日志log"><a class="anchor" aria-hidden="true" tabindex="-1" href="#日志log"><span class="octicon octicon-link"></span></a>日志log</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config format.pretty oneline <span class="token comment">#显示历史记录时,每个提交的信息只显示一行 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> config color.ui <span class="token boolean">true</span> <span class="token comment">#彩色的 git 输出 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> log <span class="token comment">#查看提交日志,从最近的提交开始显示 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> log <span class="token parameter variable">--reverse</span> <span class="token comment">#查看提交日志,从最远的提交开始显示</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>oneline <span class="token comment">#单行显示提交日志 </span>
|
||
</span><span class="code-line line-number" line="6"><span class="token function">git</span> log <span class="token parameter variable">--graph</span> <span class="token parameter variable">--pretty</span><span class="token operator">=</span>oneline --abbrev-commit
|
||
</span><span class="code-line line-number" line="7"><span class="token function">git</span> log <span class="token parameter variable">-num</span> <span class="token comment">#显示第几条log(倒数) </span>
|
||
</span><span class="code-line line-number" line="8"><span class="token function">git</span> reflog <span class="token comment">#查看所有分支的所有操作记录 </span>
|
||
</span><span class="code-line line-number" line="9"><span class="token function">git</span> log <span class="token parameter variable">--since</span><span class="token operator">=</span><span class="token number">1</span>.day <span class="token comment">#一天内的提交;你可以给出各种时间格式,比如说具体的某一天(“2008-01-15”),或者是多久以前(“2 years 1 day 3 minutes ago”)。 </span>
|
||
</span><span class="code-line line-number" line="10"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span><span class="token string">"%h - %s"</span> <span class="token parameter variable">--author</span><span class="token operator">=</span>自己的名字 <span class="token comment">#查看自己的日志 </span>
|
||
</span><span class="code-line line-number" line="11"><span class="token function">git</span> log <span class="token parameter variable">-p</span> <span class="token parameter variable">-2</span> <span class="token comment">#展开两次更新显示每次提交的内容差异 </span>
|
||
</span><span class="code-line line-number" line="12"><span class="token function">git</span> log <span class="token parameter variable">--stat</span> <span class="token comment">#要快速浏览其他协作者提交的更新都作了哪些改动 </span>
|
||
</span><span class="code-line line-number" line="13"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>format:<span class="token string">"%h - %an, %ar : %s"</span>#定制要显示的记录格式
|
||
</span><span class="code-line line-number" line="14"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>format:<span class="token string">'%h : %s'</span> --date-order <span class="token parameter variable">--graph</span> <span class="token comment"># 拓扑顺序展示 </span>
|
||
</span><span class="code-line line-number" line="15"><span class="token function">git</span> log <span class="token parameter variable">--pretty</span><span class="token operator">=</span>format:<span class="token string">'%h : %s - %ad'</span> <span class="token parameter variable">--date</span><span class="token operator">=</span>short <span class="token comment">#日期YYYY-MM-DD显示 </span>
|
||
</span><span class="code-line line-number" line="16"><span class="token function">git</span> log <span class="token operator"><</span>last tag<span class="token operator">></span> HEAD <span class="token parameter variable">--pretty</span><span class="token operator">=</span>format:%s <span class="token comment"># 只显示commit </span>
|
||
</span><span class="code-line line-number" line="17"><span class="token function">git</span> config <span class="token parameter variable">--global</span> format.pretty <span class="token string">'%h : %s - %ad'</span> <span class="token parameter variable">--date</span><span class="token operator">=</span>short <span class="token comment">#日期YYYY-MM-DD显示 写入全局配置</span>
|
||
</span></code><div onclick="copied(this)" data-code="git config format.pretty oneline #显示历史记录时,每个提交的信息只显示一行
|
||
git config color.ui true #彩色的 git 输出
|
||
git log #查看提交日志,从最近的提交开始显示
|
||
git log --reverse #查看提交日志,从最远的提交开始显示
|
||
git log --pretty=oneline #单行显示提交日志
|
||
git log --graph --pretty=oneline --abbrev-commit
|
||
git log -num #显示第几条log(倒数)
|
||
git reflog #查看所有分支的所有操作记录
|
||
git log --since=1.day #一天内的提交;你可以给出各种时间格式,比如说具体的某一天(“2008-01-15”),或者是多久以前(“2 years 1 day 3 minutes ago”)。
|
||
git log --pretty="%h - %s" --author=自己的名字 #查看自己的日志
|
||
git log -p -2 #展开两次更新显示每次提交的内容差异
|
||
git log --stat #要快速浏览其他协作者提交的更新都作了哪些改动
|
||
git log --pretty=format:"%h - %an, %ar : %s"#定制要显示的记录格式
|
||
git log --pretty=format:'%h : %s' --date-order --graph # 拓扑顺序展示
|
||
git log --pretty=format:'%h : %s - %ad' --date=short #日期YYYY-MM-DD显示
|
||
git log <last tag> HEAD --pretty=format:%s # 只显示commit
|
||
git config --global format.pretty '%h : %s - %ad' --date=short #日期YYYY-MM-DD显示 写入全局配置
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<table>
|
||
<thead>
|
||
<tr>
|
||
<th>选项</th>
|
||
<th>说明</th>
|
||
<th>选项</th>
|
||
<th>说明</th>
|
||
</tr>
|
||
</thead>
|
||
<tbody>
|
||
<tr>
|
||
<td>%H</td>
|
||
<td>提交对象(commit)的完整哈希字串</td>
|
||
<td>%ad</td>
|
||
<td>作者修订日期(可以用 -date= 选项定制格式)</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%h</td>
|
||
<td>提交对象的简短哈希字串</td>
|
||
<td>%ar</td>
|
||
<td>作者修订日期,按多久以前的方式显示</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%T</td>
|
||
<td>树对象(tree)的完整哈希字串</td>
|
||
<td>%cn</td>
|
||
<td>提交者(committer)的名字</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%t</td>
|
||
<td>树对象的简短哈希字串</td>
|
||
<td>%ce</td>
|
||
<td>提交者的电子邮件地址</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%P</td>
|
||
<td>父对象(parent)的完整哈希字串</td>
|
||
<td>%cd</td>
|
||
<td>提交日期</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%p</td>
|
||
<td>父对象的简短哈希字串</td>
|
||
<td>%cr</td>
|
||
<td>提交日期,按多久以前的方式显示</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%an</td>
|
||
<td>作者(author)的名字</td>
|
||
<td>%s</td>
|
||
<td>提交说明</td>
|
||
</tr>
|
||
<tr>
|
||
<td>%ae</td>
|
||
<td>作者的电子邮件地址</td>
|
||
<td>-</td>
|
||
<td>-</td>
|
||
</tr>
|
||
</tbody>
|
||
</table>
|
||
<p><a href="https://git-scm.com/docs/git-log#_pretty_formats">Pretty Formats</a></p>
|
||
<h2 id="重写历史"><a class="anchor" aria-hidden="true" tabindex="-1" href="#重写历史"><span class="octicon octicon-link"></span></a>重写历史</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> commit <span class="token parameter variable">--amend</span> <span class="token comment"># 改变最近一次提交 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> rebase <span class="token parameter variable">-i</span> HEAD~3 <span class="token comment"># 修改最近三次的提交说明,或者其中任意一次 </span>
|
||
</span><span class="code-line line-number" line="3"><span class="token function">git</span> commit <span class="token parameter variable">--amend</span> <span class="token comment"># 保存好了,这些指示很明确地告诉了你该干什么 </span>
|
||
</span><span class="code-line line-number" line="4"><span class="token function">git</span> rebase <span class="token parameter variable">--continue</span> <span class="token comment"># 修改提交说明,退出编辑器。 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git commit --amend # 改变最近一次提交
|
||
git rebase -i HEAD~3 # 修改最近三次的提交说明,或者其中任意一次
|
||
git commit --amend # 保存好了,这些指示很明确地告诉了你该干什么
|
||
git rebase --continue # 修改提交说明,退出编辑器。
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1">pick f7f3f6d changed my name a bit
|
||
</span><span class="code-line line-number" line="2">pick 310154e updated README formatting and added blame
|
||
</span><span class="code-line line-number" line="3">pick a5f4a0d added cat-file
|
||
</span></code><div onclick="copied(this)" data-code="pick f7f3f6d changed my name a bit
|
||
pick 310154e updated README formatting and added blame
|
||
pick a5f4a0d added cat-file
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>改成</p>
|
||
<pre><code class="code-highlight"><span class="code-line line-number" line="1">pick 310154e updated README formatting and added blame
|
||
</span><span class="code-line line-number" line="2">pick f7f3f6d changed my name a bit
|
||
</span></code><div onclick="copied(this)" data-code="pick 310154e updated README formatting and added blame
|
||
pick f7f3f6d changed my name a bit
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h3 id="删除仓库"><a class="anchor" aria-hidden="true" tabindex="-1" href="#删除仓库"><span class="octicon octicon-link"></span></a>删除仓库</h3>
|
||
<pre><code class="code-highlight"><span class="code-line line-number" line="1">cd ..
|
||
</span><span class="code-line line-number" line="2">rm -rf repo.git
|
||
</span></code><div onclick="copied(this)" data-code="cd ..
|
||
rm -rf repo.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><a href="https://help.github.com/articles/changing-author-info/">Github官方教程</a></p>
|
||
<h2 id="其它"><a class="anchor" aria-hidden="true" tabindex="-1" href="#其它"><span class="octicon octicon-link"></span></a>其它</h2>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> <span class="token builtin class-name">help</span> * <span class="token comment"># 获取命令的帮助信息 </span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">git</span> status <span class="token comment"># 获取当前的状态,非常有用,因为git会提示接下来的能做的操作 </span>
|
||
</span></code><div onclick="copied(this)" data-code="git help * # 获取命令的帮助信息
|
||
git status # 获取当前的状态,非常有用,因为git会提示接下来的能做的操作
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="报错问题解决"><a class="anchor" aria-hidden="true" tabindex="-1" href="#报错问题解决"><span class="octicon octicon-link"></span></a>报错问题解决</h2>
|
||
<p><strong>1. <code>git fatal: protocol error: bad line length character: No s</code></strong></p>
|
||
<p>解决办法:更换remote地址为 <code>http/https</code> 的</p>
|
||
<p><strong>2. <code>The requested URL returned error: 403 Forbidden while accessing</code></strong></p>
|
||
<p>解决github push错误的办法:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token comment">#vim 编辑器打开 当前项目中的config文件</span>
|
||
</span><span class="code-line line-number" line="2"><span class="token function">vim</span> .git/config
|
||
</span><span class="code-line line-number" line="3">
|
||
</span><span class="code-line line-number" line="4"><span class="token comment">#修改</span>
|
||
</span><span class="code-line line-number" line="5"><span class="token punctuation">[</span>remote <span class="token string">"origin"</span><span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="6"> url <span class="token operator">=</span> https://github.com/jaywcjlove/example.git
|
||
</span><span class="code-line line-number" line="7">
|
||
</span><span class="code-line line-number" line="8"><span class="token comment">#为下面代码</span>
|
||
</span><span class="code-line line-number" line="9"><span class="token punctuation">[</span>remote <span class="token string">"origin"</span><span class="token punctuation">]</span>
|
||
</span><span class="code-line line-number" line="10"> url <span class="token operator">=</span> https://jaywcjlove@github.com/jaywcjlove/example.git
|
||
</span></code><div onclick="copied(this)" data-code="#vim 编辑器打开 当前项目中的config文件
|
||
vim .git/config
|
||
|
||
#修改
|
||
[remote "origin"]
|
||
url = https://github.com/jaywcjlove/example.git
|
||
|
||
#为下面代码
|
||
[remote "origin"]
|
||
url = https://jaywcjlove@github.com/jaywcjlove/example.git
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p><strong>3. git status 显示中文问题</strong></p>
|
||
<p>在查看状态的时候 git status 如果是中文就显示下面的情况</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token punctuation">\</span><span class="token number">344</span><span class="token punctuation">\</span><span class="token number">272</span><span class="token punctuation">\</span><span class="token number">247</span><span class="token punctuation">\</span><span class="token number">345</span><span class="token punctuation">\</span><span class="token number">223</span><span class="token punctuation">\</span><span class="token number">201</span><span class="token punctuation">\</span><span class="token number">351</span><span class="token punctuation">\</span><span class="token number">234</span><span class="token punctuation">\</span><span class="token number">200</span><span class="token punctuation">\</span><span class="token number">346</span><span class="token punctuation">\</span><span class="token number">261</span><span class="token punctuation">\</span><span class="token number">202</span>
|
||
</span></code><div onclick="copied(this)" data-code="\344\272\247\345\223\201\351\234\200\346\261\202
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<p>解决这个问题方法是:</p>
|
||
<pre class="language-shell"><code class="language-shell code-highlight"><span class="code-line line-number" line="1"><span class="token function">git</span> config <span class="token parameter variable">--global</span> core.quotepath <span class="token boolean">false</span>
|
||
</span></code><div onclick="copied(this)" data-code="git config --global core.quotepath false
|
||
" class="copied"><svg class="octicon-copy" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M0 6.75C0 5.784.784 5 1.75 5h1.5a.75.75 0 010 1.5h-1.5a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-1.5a.75.75 0 011.5 0v1.5A1.75 1.75 0 019.25 16h-7.5A1.75 1.75 0 010 14.25v-7.5z"></path><path fill-rule="evenodd" d="M5 1.75C5 .784 5.784 0 6.75 0h7.5C15.216 0 16 .784 16 1.75v7.5A1.75 1.75 0 0114.25 11h-7.5A1.75 1.75 0 015 9.25v-7.5zm1.75-.25a.25.25 0 00-.25.25v7.5c0 .138.112.25.25.25h7.5a.25.25 0 00.25-.25v-7.5a.25.25 0 00-.25-.25h-7.5z"></path></svg><svg class="octicon-check" aria-hidden="true" viewBox="0 0 16 16" fill="currentColor" height="12" width="12"><path fill-rule="evenodd" d="M13.78 4.22a.75.75 0 010 1.06l-7.25 7.25a.75.75 0 01-1.06 0L2.22 9.28a.75.75 0 011.06-1.06L6 10.94l6.72-6.72a.75.75 0 011.06 0z"></path></svg></div></pre>
|
||
<h2 id="参考资料"><a class="anchor" aria-hidden="true" tabindex="-1" href="#参考资料"><span class="octicon octicon-link"></span></a>参考资料</h2>
|
||
<ul>
|
||
<li><a href="http://git-scm.com/">Git官网</a></li>
|
||
<li><a href="https://try.github.io/"><strong>Github 15分钟学习Git</strong></a></li>
|
||
<li><a href="http://gitref.org/zh/index.html">Git参考手册</a></li>
|
||
<li><a href="http://www.mceiba.com/tool/git-cheat-sheet.html">Git简明手册</a></li>
|
||
<li><a href="http://www-cs-students.stanford.edu/~blynn/gitmagic/intl/zh_cn/">Git Magic</a></li>
|
||
<li><a href="http://gitbook.liuhui998.com/index.html">Git Community Book 中文版</a></li>
|
||
<li><a href="http://git-scm.com/book/en/v2">Pro Git</a></li>
|
||
<li><a href="http://marklodato.github.io/visual-git-guide/index-zh-cn.html">图解Git</a></li>
|
||
<li><a href="http://rogerdudler.github.io/git-guide/index.zh.html">git-简明指南</a></li>
|
||
<li><a href="http://pcottle.github.io/learnGitBranching/">learnGitBranching 在线学习工具</a></li>
|
||
<li><a href="http://rogerdudler.github.io/git-guide/index.zh.html">初级教程</a></li>
|
||
<li><a href="http://www.liaoxuefeng.com/wiki/0013739516305929606dd18361248578c67b8067c8c017b000">廖雪峰的Git教程</a></li>
|
||
<li><a href="http://www.worldhello.net/gotgithub/">蒋鑫老师将带你入github的大门</a></li>
|
||
<li><a href="http://www.open-open.com/lib/view/open1328069609436.html">git详解</a></li>
|
||
<li><a href="http://git.oschina.net/progit/">oschina教程</a></li>
|
||
<li><a href="https://github.com/blog/2019-how-to-undo-almost-anything-with-git">How to undo (almost) anything with Git撤销一切,汇总各种回滚撤销的场景,加强学习。</a></li>
|
||
<li><a href="http://www.runoob.com/git/git-tutorial.html">Git 教程 | 菜鸟教程runoob.com</a></li>
|
||
<li><a href="https://gold.xitu.io/post/5842f9b861ff4b005889ade6">Git 本地仓库和裸仓库</a></li>
|
||
<li><a href="http://www.kancloud.cn/kancloud/igit/46710">沉浸式学 Git</a></li>
|
||
<li><a href="http://way.oschina.io/2016/12/15/notes/GitAdvance/?utm_source=gank.io&utm_medium=email">Git进阶用法,主要是rebase高级用法</a></li>
|
||
</ul>
|
||
<style>markdown-style pre .copied {
|
||
display: flex;
|
||
position: absolute;
|
||
cursor: pointer;
|
||
color: #a5afbb;
|
||
top: 6px;
|
||
right: 6px;
|
||
border-radius: 5px;
|
||
background: #82828226;
|
||
padding: 6px;
|
||
font-size: 12px;
|
||
transition: all .3s;
|
||
}
|
||
markdown-style pre .copied:not(.active) {
|
||
visibility: hidden;
|
||
}
|
||
markdown-style pre:hover .copied {
|
||
visibility: visible;
|
||
}
|
||
markdown-style pre:hover .copied:hover {
|
||
background: #4caf50;
|
||
color: #fff;
|
||
}
|
||
markdown-style pre:hover .copied:active,
|
||
markdown-style pre .copied.active {
|
||
background: #2e9b33;
|
||
color: #fff;
|
||
}
|
||
markdown-style pre .copied .octicon-copy {
|
||
display: block;
|
||
}
|
||
markdown-style pre .copied .octicon-check {
|
||
display: none;
|
||
}
|
||
markdown-style pre .active .octicon-copy {
|
||
display: none;
|
||
}
|
||
markdown-style pre .active .octicon-check {
|
||
display: block;
|
||
}</style><script>/*! @uiw/copy-to-clipboard v1.0.12 | MIT (c) 2021 Kenny Wang | https://github.com/uiwjs/copy-to-clipboard.git */
|
||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).copyTextToClipboard=t()}(this,(function(){"use strict";return function(e,t){const o=document.createElement("textarea");o.value=e,o.setAttribute("readonly",""),o.style={position:"absolute",left:"-9999px"},document.body.appendChild(o);const n=document.getSelection().rangeCount>0&&document.getSelection().getRangeAt(0);o.select();let c=!1;try{c=!!document.execCommand("copy")}catch(e){c=!1}document.body.removeChild(o),n&&document.getSelection&&(document.getSelection().removeAllRanges(),document.getSelection().addRange(n)),t&&t(c)}}));
|
||
|
||
function copied(target, str) {
|
||
target.classList.add('active');
|
||
copyTextToClipboard(target.dataset.code, function() {
|
||
setTimeout(() => {
|
||
target.classList.remove('active');
|
||
}, 2000);
|
||
});
|
||
}</script></markdown-style>
|
||
|
||
</div>
|
||
<!-- Linux命令行搜索引擎:https://jaywcjlove.github.io/linux-command/ -->
|
||
<div class="footer ">
|
||
<a target="_blank" href="https://github.com/jaywcjlove/linux-command/new/master/command">添加命令</a> |
|
||
<a href="../hot.html">命令列表</a> |
|
||
<a href="https://github.com/jaywcjlove/oscnews" target="_blank">Chrome 插件</a> |
|
||
<a href="https://github.com/jaywcjlove/linux-command/releases" target="_blank">Alfred</a> |
|
||
<a href="https://jaywcjlove.github.io/linux-command/linux-command.docset.zip" target="_blank">Dash</a> |
|
||
<a href="https://github.com/roachsinai/krunner-linuxcommands" target="_blank">Krunner</a> |
|
||
<a href="http://jaywcjlove.gitee.io/linux-command/" target="_blank">开源中国Web版</a>
|
||
<br />
|
||
<a href="https://jaywcjlove.github.io/#/sponsor" target="_blank">打赏捐赠</a> |
|
||
<a href="https://github.com/jaywcjlove/linux-command" target="_blank">Github</a> |
|
||
<a href="https://jaywcjlove.github.io/linux-command/" target="_blank">短地址:https://git.io/linux</a>
|
||
<br />
|
||
收藏本站请使用 Ctrl+D 或者Command+d
|
||
<br /> 共搜集到
|
||
<span id="commands_info">
|
||
611
|
||
</span> 个Linux命令,超过 <a href="../contributors.html">50+</a> 贡献者
|
||
</div>
|
||
<script type="text/javascript" src="../js/dt.js?v=1747070672619"></script>
|
||
<script type="text/javascript" src="../js/index.js?v=1747070672619"></script>
|
||
</body>
|
||
</html> |