[{"data":1,"prerenderedAt":818},["ShallowReactive",2],{"content-query-SFqRkV0yvM":3},{"_path":4,"_dir":5,"_draft":6,"_partial":6,"_locale":7,"title":8,"description":9,"date":10,"cover":11,"type":12,"body":13,"_type":812,"_id":813,"_source":814,"_file":815,"_stem":816,"_extension":817},"/technology-blogs/zh/580","zh",false,"","【git 和gitee 从入门到实践】 git + gitee 入门实践","gitee+git才是王道~","2021-05-31","https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2021/05/31/28f9ef1cbffa435ab6d331355fc08c95.png","technology-blogs",{"type":14,"children":15,"toc":801},"root",[16,24,39,51,62,67,72,78,92,98,111,117,122,128,139,148,153,158,163,171,176,181,192,197,205,210,218,223,231,236,241,247,252,260,265,273,278,283,288,293,298,303,311,316,321,326,333,338,343,348,353,361,366,371,376,381,386,391,396,404,409,414,419,424,429,434,439,444,449,454,459,467,472,480,486,491,499,504,509,514,519,524,532,537,542,547,552,556,561,566,571,576,581,586,591,596,601,620,627,632,637,642,647,652,657,661,669,674,679,684,689,693,701,706,712,717,722,727,732,737,742,747,755,759,764,769,774,779,787,792],{"type":17,"tag":18,"props":19,"children":21},"element","h1",{"id":20},"git-和gitee-从入门到实践-git-gitee-入门实践",[22],{"type":23,"value":8},"text",{"type":17,"tag":25,"props":26,"children":27},"p",{},[28,30],{"type":23,"value":29},"作者：",{"type":17,"tag":31,"props":32,"children":36},"a",{"href":33,"rel":34},"https://bbs.huaweicloud.com/forum/home.php?mod=space&uid=224825&do=thread",[35],"nofollow",[37],{"type":23,"value":38},"琦玉",{"type":17,"tag":25,"props":40,"children":41},{},[42,44],{"type":23,"value":43},"来源：",{"type":17,"tag":31,"props":45,"children":48},{"href":46,"rel":47},"https://bbs.huaweicloud.com/forum/forum-1076-1.html",[35],[49],{"type":23,"value":50},"MindSpore论坛",{"type":17,"tag":25,"props":52,"children":53},{},[54,56],{"type":23,"value":55},"原帖：",{"type":17,"tag":31,"props":57,"children":60},{"href":58,"rel":59},"https://bbs.huaweicloud.com/forum/thread-55222-1-1.html",[35],[61],{"type":23,"value":58},{"type":17,"tag":18,"props":63,"children":65},{"id":64},"写在前面",[66],{"type":23,"value":64},{"type":17,"tag":25,"props":68,"children":69},{},[70],{"type":23,"value":71},"作为一个编程小白，刚开始的时候完全不知道git为何物，但招聘简历上很多岗位都提到了这个词，本着跟我无关高高挂起的懒惰原则，我坚决不看哈哈哈。但小编我最近换了份工作，日常生活中中与这个名词接触的次数大大增加，让我实在是没有办法啊，花点时间来了解一下这git到底是什么，不求融会贯通，至少要入个门吧，于是就在学习的过程中写下了这篇入门笔记，很多人说git+GitHub才是王道，不好意思我觉得gitee的中文名太让我出戏了，哈哈哈，项目也开源在gitee上，所以决定试一下这个组合。实践过程中明确感受到gitee+git是简单易上手的，大家完全不用担心会被“劝退”~话不多说，让我们进入正题吧。",{"type":17,"tag":18,"props":73,"children":75},{"id":74},"gitee简介",[76],{"type":23,"value":77},"Gitee简介",{"type":17,"tag":25,"props":79,"children":80},{},[81,83,90],{"type":23,"value":82},"大名鼎鼎的码云哈哈哈，再笑一下。Gitee是开源中国开发的一款基于git的代码托管平台，能够实现的功能有很多，代码托管，项目管理啊，写作开发等等，目前是国内代码系统的扛把子，前言中提到的GitHub和gitee的作用和性质是高度相似的，但两者有这两个显著的不同：gitee速度快（百度的），gitee支持免费的私密项目。有兴趣了解更多一点的朋友们可以去码云平台帮助文档好好了解一下，地址：",{"type":17,"tag":31,"props":84,"children":87},{"href":85,"rel":86},"https://bbs.huaweicloud.com/forum/thread-55222-1-1.html#",[35],[88],{"type":23,"value":89},"http://git.mydoc.io/",{"type":23,"value":91}," 这文档写的很好，主要全是中文（废话）还通俗易懂，推荐大家好好看看。",{"type":17,"tag":18,"props":93,"children":95},{"id":94},"gitee注册",[96],{"type":23,"value":97},"Gitee注册",{"type":17,"tag":25,"props":99,"children":100},{},[101,103,109],{"type":23,"value":102},"直接访问",{"type":17,"tag":31,"props":104,"children":107},{"href":105,"rel":106},"https://gitee.com/signup",[35],[108],{"type":23,"value":105},{"type":23,"value":110},",注册一个就行",{"type":17,"tag":18,"props":112,"children":114},{"id":113},"git简介",[115],{"type":23,"value":116},"Git简介",{"type":17,"tag":25,"props":118,"children":119},{},[120],{"type":23,"value":121},"git是一个分布式的开源版本控制系统，git是一种技术或者说是工具，可以有效，高速的处理从小到大的项目版本管理。而gitee是基于git的代码托管平台，理解他们的区别非常重要。一个经典的git开发过程:1从服务器上克隆完整的Git仓库到单机上。2在自己的机器上根据不同的开发目的，创建分支并修改代码。3在单机上自己创建的分支上提交代码。4在单机上合并分支。5把服务器上最新版的代码fetch下来，然后跟自己的主分支合并。6生成补丁（patch），把补丁发给主开发者。7看主开发者的反馈，如果主开发者发现两个一般开发者之间之间有冲突，就要求他们先解决冲突，然后再由其中一人提交，如果主开发者可以解决冲突或者没有冲突，就通过。",{"type":17,"tag":18,"props":123,"children":125},{"id":124},"git安装",[126],{"type":23,"value":127},"Git安装",{"type":17,"tag":25,"props":129,"children":130},{},[131,133],{"type":23,"value":132},"要安装先下载嘛，网址",{"type":17,"tag":31,"props":134,"children":136},{"href":85,"rel":135},[35],[137],{"type":23,"value":138},"https://git-scm.com/downloads",{"type":17,"tag":25,"props":140,"children":141},{},[142],{"type":17,"tag":143,"props":144,"children":147},"img",{"alt":145,"src":146},"20200509-162259(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/095929tszp87wsemsl3qmi.png",[],{"type":17,"tag":25,"props":149,"children":150},{},[151],{"type":23,"value":152},"根据自己的需要来下载相应的版本，小编这里是win10的环境，安装了win10x64，对于git的windows安装，其实一路next就行了，next到底都不需要配置环境变量，会自动给你配置好，蛮方便的。",{"type":17,"tag":25,"props":154,"children":155},{},[156],{"type":23,"value":157},"怎么验证你到底安装成功还是失败了呢？",{"type":17,"tag":25,"props":159,"children":160},{},[161],{"type":23,"value":162},"打开cmd，输入git --version 如果出现版本信息，那你就装成功了，像我下面这样：",{"type":17,"tag":25,"props":164,"children":165},{},[166],{"type":17,"tag":143,"props":167,"children":170},{"alt":168,"src":169},"20200507-171633(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/10094445t0xmbyvfxnb97y.png",[],{"type":17,"tag":18,"props":172,"children":174},{"id":173},"代码托管",[175],{"type":23,"value":173},{"type":17,"tag":25,"props":177,"children":178},{},[179],{"type":23,"value":180},"Gitee已经注册好了，git也安装成功了，那么我们试一试代码托管功能吧。在开始之前，我们来讲git中四个比较重要的概念",{"type":17,"tag":25,"props":182,"children":183},{},[184,190],{"type":17,"tag":185,"props":186,"children":187},"strong",{},[188],{"type":23,"value":189},"1. git branch命令（分支",{"type":23,"value":191},"）",{"type":17,"tag":25,"props":193,"children":194},{},[195],{"type":23,"value":196},"git默认的分支一般是master，当然一般默认的东西都是可以修改的。我们在master完成一次开发，生成了一个稳定版本，那么当需要添加新功能或者做修改时，只需要新建一个分支，然后在这个分支上面开发，完成之后合并到主分支即可，分支功能解决的是正在开发的版本与上线版本稳定性冲突的问题。",{"type":17,"tag":25,"props":198,"children":199},{},[200],{"type":17,"tag":185,"props":201,"children":202},{},[203],{"type":23,"value":204},"2. git commit命令（提交）",{"type":17,"tag":25,"props":206,"children":207},{},[208],{"type":23,"value":209},"git对于版本的管理其实是对提交的管理，git用40个字节长度的16进制字符串来标识每一个提交，每一个提交具有唯一的标识，可以根据这个标识任意回退。",{"type":17,"tag":25,"props":211,"children":212},{},[213],{"type":17,"tag":185,"props":214,"children":215},{},[216],{"type":23,"value":217},"3. git pull命令（拉取）",{"type":17,"tag":25,"props":219,"children":220},{},[221],{"type":23,"value":222},"用于取回远程仓库某个分支的更新，再与本地仓库进行合并。",{"type":17,"tag":25,"props":224,"children":225},{},[226],{"type":17,"tag":185,"props":227,"children":228},{},[229],{"type":23,"value":230},"4. git push命令（推送）",{"type":17,"tag":25,"props":232,"children":233},{},[234],{"type":23,"value":235},"用于把本地的代码更新到远程仓库。",{"type":17,"tag":25,"props":237,"children":238},{},[239],{"type":23,"value":240},"了解了这些基础概念，我们开始正式学习git+gitee的使用。",{"type":17,"tag":242,"props":243,"children":245},"h2",{"id":244},"创建远程代码库",[246],{"type":23,"value":244},{"type":17,"tag":25,"props":248,"children":249},{},[250],{"type":23,"value":251},"登录自己的gitee账号，选择“新建项目”",{"type":17,"tag":25,"props":253,"children":254},{},[255],{"type":17,"tag":143,"props":256,"children":259},{"alt":257,"src":258},"20200508-092701(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/101046s8krcofti9vt4tm1.png",[],{"type":17,"tag":25,"props":261,"children":262},{},[263],{"type":23,"value":264},"这边我在自己码云创建了一个“testGit”的仓库，下面选择是否公开，根据个人需求选择，同时勾选“使用Readme文件初始化这个项目”，点击新建之后，可以看到远程代码仓库创建成功，同时库内有一个README.md文件：",{"type":17,"tag":25,"props":266,"children":267},{},[268],{"type":17,"tag":143,"props":269,"children":272},{"alt":270,"src":271},"20200511-141640(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/101114xhaw83xgqeuxxrmu.png",[],{"type":17,"tag":25,"props":274,"children":275},{},[276],{"type":23,"value":277},"这就表示你创建成功啦。",{"type":17,"tag":242,"props":279,"children":281},{"id":280},"创建本地代码仓库",[282],{"type":23,"value":280},{"type":17,"tag":25,"props":284,"children":285},{},[286],{"type":23,"value":287},"在本地电脑的一个盘下新建一个文件夹来作为自己的本地代码仓库，也就是说以后希望这个文件夹里面的改动都能够被git进行管理，我这边是在D盘下面新建了一个文件夹，暂且也命名为testGit，方便记忆。",{"type":17,"tag":25,"props":289,"children":290},{},[291],{"type":23,"value":292},"进入文件夹，按住shift键的同时在空白处右击鼠标，选择“在此处打开Powershell窗口”，执行代码：",{"type":17,"tag":25,"props":294,"children":295},{},[296],{"type":23,"value":297},"git init",{"type":17,"tag":25,"props":299,"children":300},{},[301],{"type":23,"value":302},"(这句话的意思是初始化一个本地仓库，之后可以看到文件夹下面多了一个.git文件夹，这个文件夹可能是隐藏文件夹，需要在根目录下设置所有文件可见，用于记录所有与管理本仓库相关的文件，请小心改动)",{"type":17,"tag":25,"props":304,"children":305},{},[306],{"type":17,"tag":143,"props":307,"children":310},{"alt":308,"src":309},"20200511-140737(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/111506accf6wpuohvypxpj.png",[],{"type":17,"tag":242,"props":312,"children":314},{"id":313},"进行代码托管",[315],{"type":23,"value":313},{"type":17,"tag":25,"props":317,"children":318},{},[319],{"type":23,"value":320},"本地仓库和远程代码仓库现在都已经建立好了，我们要将他们进行同步才能在gitee上进行代码托管。",{"type":17,"tag":25,"props":322,"children":323},{},[324],{"type":23,"value":325},"1. 本地代码仓库与远程代码仓库进行同步，执行代码：",{"type":17,"tag":25,"props":327,"children":328},{},[329],{"type":17,"tag":143,"props":330,"children":332},{"alt":7,"src":331},"https://obs-mindspore-file.obs.cn-north-4.myhuaweicloud.com/file/2022/08/10/3e71ec75671e4089a63b3c6e130ffb3d.png",[],{"type":17,"tag":25,"props":334,"children":335},{},[336],{"type":23,"value":337},"2. 拉取远程代码库：",{"type":17,"tag":25,"props":339,"children":340},{},[341],{"type":23,"value":342},"我的远程库上有两个文件，但是目前新建的代码库中没有这两个文件，所以先执行pull操作将远程仓库拉取合并到本地仓库，否则会出错，执行代码:",{"type":17,"tag":25,"props":344,"children":345},{},[346],{"type":23,"value":347},"git pull origin master",{"type":17,"tag":25,"props":349,"children":350},{},[351],{"type":23,"value":352},"此处第一次执行git pull是没有用的，因为本地创建了代码仓库，目前git默认的关联库就是在本地。需要执行git pull origin master命令才行，这句话的意思是推送到远程库的master分支，以后就可以直接使用git pull命令了。",{"type":17,"tag":25,"props":354,"children":355},{},[356],{"type":17,"tag":143,"props":357,"children":360},{"alt":358,"src":359},"20200511-144530(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112343yi8omhulehy9d6gn.png",[],{"type":17,"tag":25,"props":362,"children":363},{},[364],{"type":23,"value":365},"当然这一步的时候会遇到一些问题，我在拉取的时候没有遇到，但我在网上看其他的一些学习笔记的时候，这个问题出现的还是蛮常见的，所以在这里拿出来讲讲。错误提示：“fatal:refusing to merge unrelated histories”，出现这种错误是因为git认为这两个仓库不同所以无法合并，我们执行语句的时候这样写就行了：",{"type":17,"tag":25,"props":367,"children":368},{},[369],{"type":23,"value":370},"git pull origin master –allow-unrelated-histories",{"type":17,"tag":25,"props":372,"children":373},{},[374],{"type":23,"value":375},"3. 向远程代码库推送文件：",{"type":17,"tag":25,"props":377,"children":378},{},[379],{"type":23,"value":380},"这里我做一个简单的操作，在本地新建一个名为test1.txt的文本文件，现在要将他推送到远程仓库里面去。此时第一步代码是",{"type":17,"tag":25,"props":382,"children":383},{},[384],{"type":23,"value":385},"git add .",{"type":17,"tag":25,"props":387,"children":388},{},[389],{"type":23,"value":390},"这一步是将当前工作区的所有文件存放到暂存区",{"type":17,"tag":25,"props":392,"children":393},{},[394],{"type":23,"value":395},"当然这一步执行的时候会遇到一个问题， 我这边遇到的时候比较懵，问题如下：",{"type":17,"tag":25,"props":397,"children":398},{},[399],{"type":17,"tag":143,"props":400,"children":403},{"alt":401,"src":402},"20200511-154930(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112458glqkz8okyf5bbh6g.png",[],{"type":17,"tag":25,"props":405,"children":406},{},[407],{"type":23,"value":408},"我比较单纯，按照提示的输入了git config –global user.email”xxxxxxxx(我的邮箱)”和git config –global user.name”xxxxx(我的用户名)”。结束之后一运行发现，不行。。。。。",{"type":17,"tag":25,"props":410,"children":411},{},[412],{"type":23,"value":413},"这就很尴尬了，试了几次之后找到了一个完全可行的方法，在本地仓库中打开.git文件夹，再打开config文件，添加下面一段：",{"type":17,"tag":25,"props":415,"children":416},{},[417],{"type":23,"value":418},"[user]",{"type":17,"tag":25,"props":420,"children":421},{},[422],{"type":23,"value":423},"email = 你的邮箱",{"type":17,"tag":25,"props":425,"children":426},{},[427],{"type":23,"value":428},"name = 你的用户名",{"type":17,"tag":25,"props":430,"children":431},{},[432],{"type":23,"value":433},"重点是，这边输入的时候必须要是英文输入，包括标点符号等号之类的，否则还会报错，但是你设置好之后，上面那个问题就解决了。",{"type":17,"tag":25,"props":435,"children":436},{},[437],{"type":23,"value":438},"此时你再运行：",{"type":17,"tag":25,"props":440,"children":441},{},[442],{"type":23,"value":443},"git commit –m”对该操作的描述”",{"type":17,"tag":25,"props":445,"children":446},{},[447],{"type":23,"value":448},"此时git已经感觉到了仓库中的变化，我们这时候再运行：",{"type":17,"tag":25,"props":450,"children":451},{},[452],{"type":23,"value":453},"git push",{"type":17,"tag":25,"props":455,"children":456},{},[457],{"type":23,"value":458},"将本地的同步到远程代码仓库",{"type":17,"tag":25,"props":460,"children":461},{},[462],{"type":17,"tag":143,"props":463,"children":466},{"alt":464,"src":465},"20200511-162035(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112605zcmxdqxj8luybuju.png",[],{"type":17,"tag":25,"props":468,"children":469},{},[470],{"type":23,"value":471},"操作截图如上图所示，这时候我们再返回远程代码端，刷新一下网页，就可以看到test1.txt已经出现再远程代码端啦！",{"type":17,"tag":25,"props":473,"children":474},{},[475],{"type":17,"tag":143,"props":476,"children":479},{"alt":477,"src":478},"20200511-162119(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112657l9hd0kpekhdvoiop.png",[],{"type":17,"tag":18,"props":481,"children":483},{"id":482},"删除回退版本",[484],{"type":23,"value":485},"删除，回退版本",{"type":17,"tag":25,"props":487,"children":488},{},[489],{"type":23,"value":490},"提交跟拉取远程的学会了，那我们现在试试看删除跟回退，我们以删除文件夹和文件为例子，本地已经有文件test1.txt文件了，这里我们在本地新建一个文件夹abc，同时先根据上面的操作把这个文件夹推送到远程代码仓库。我在推送时遇到了一个问题：",{"type":17,"tag":25,"props":492,"children":493},{},[494],{"type":17,"tag":143,"props":495,"children":498},{"alt":496,"src":497},"20200512-171005(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112756b58bk3hu7b4zbt5f.png",[],{"type":17,"tag":25,"props":500,"children":501},{},[502],{"type":23,"value":503},"查了一下是分支的原因，我们先创建一个新的分支：",{"type":17,"tag":25,"props":505,"children":506},{},[507],{"type":23,"value":508},"git branch newbranch",{"type":17,"tag":25,"props":510,"children":511},{},[512],{"type":23,"value":513},"然后查看一下当前分支;",{"type":17,"tag":25,"props":515,"children":516},{},[517],{"type":23,"value":518},"git branch",{"type":17,"tag":25,"props":520,"children":521},{},[522],{"type":23,"value":523},"如下图所示：",{"type":17,"tag":25,"props":525,"children":526},{},[527],{"type":17,"tag":143,"props":528,"children":531},{"alt":529,"src":530},"20200512-171316(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112824zzp0svamrl5plfui.png",[],{"type":17,"tag":25,"props":533,"children":534},{},[535],{"type":23,"value":536},"前面有*号的表示是当前所在的分支，这时候我们就要切换过来：",{"type":17,"tag":25,"props":538,"children":539},{},[540],{"type":23,"value":541},"git checkout newbranch",{"type":17,"tag":25,"props":543,"children":544},{},[545],{"type":23,"value":546},"这时候就已经切换过来了，不放心的git branch再看一眼",{"type":17,"tag":25,"props":548,"children":549},{},[550],{"type":23,"value":551},"然后将你的改动提交到新的分支上",{"type":17,"tag":25,"props":553,"children":554},{},[555],{"type":23,"value":385},{"type":17,"tag":25,"props":557,"children":558},{},[559],{"type":23,"value":560},"git commit –m “你的说明”",{"type":17,"tag":25,"props":562,"children":563},{},[564],{"type":23,"value":565},"然后检查是否成功 git status 切换到主分支：",{"type":17,"tag":25,"props":567,"children":568},{},[569],{"type":23,"value":570},"Git checkout master",{"type":17,"tag":25,"props":572,"children":573},{},[574],{"type":23,"value":575},"将新分支提交的 改动合并到主分支上:",{"type":17,"tag":25,"props":577,"children":578},{},[579],{"type":23,"value":580},"git merge newbranch",{"type":17,"tag":25,"props":582,"children":583},{},[584],{"type":23,"value":585},"然后就可以推送到远程代码仓了：",{"type":17,"tag":25,"props":587,"children":588},{},[589],{"type":23,"value":590},"git push –u origin master",{"type":17,"tag":25,"props":592,"children":593},{},[594],{"type":23,"value":595},"最后把这个分支删除掉：",{"type":17,"tag":25,"props":597,"children":598},{},[599],{"type":23,"value":600},"git branch –D newbranch",{"type":17,"tag":25,"props":602,"children":603},{},[604,606,611,613,618],{"type":23,"value":605},"我在这边还遇到一个特别憨憨的问题，实在是尴尬，在本地新建了一个空的文件夹，怎么同步都同步不到远程代码仓库，后来才发现，",{"type":17,"tag":185,"props":607,"children":608},{},[609],{"type":23,"value":610},"无",{"type":23,"value":612},"法",{"type":17,"tag":185,"props":614,"children":615},{},[616],{"type":23,"value":617},"同步****空文件夹到远程仓库",{"type":23,"value":619},"，因为git默认本地文件夹没有改动。",{"type":17,"tag":621,"props":622,"children":624},"h3",{"id":623},"_1-删除文件",[625],{"type":23,"value":626},"1. 删除文件",{"type":17,"tag":25,"props":628,"children":629},{},[630],{"type":23,"value":631},"执行下面的命令：",{"type":17,"tag":25,"props":633,"children":634},{},[635],{"type":23,"value":636},"git rm 想要删除的文件和其后缀",{"type":17,"tag":25,"props":638,"children":639},{},[640],{"type":23,"value":641},"git rm 想要删除的文件夹的名字 –r",{"type":17,"tag":25,"props":643,"children":644},{},[645],{"type":23,"value":646},"示例：git rm test1.txt",{"type":17,"tag":25,"props":648,"children":649},{},[650],{"type":23,"value":651},"此处删除的是test1.txt本地文件，我们还要同步到远程代码仓库里面去：",{"type":17,"tag":25,"props":653,"children":654},{},[655],{"type":23,"value":656},"git commit –m “删除test1.txt”",{"type":17,"tag":25,"props":658,"children":659},{},[660],{"type":23,"value":453},{"type":17,"tag":25,"props":662,"children":663},{},[664],{"type":17,"tag":143,"props":665,"children":668},{"alt":666,"src":667},"20200512-191450(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/112946mjc5y03hh9ircdvh.png",[],{"type":17,"tag":25,"props":670,"children":671},{},[672],{"type":23,"value":673},"远程代码仓库刷新一下就会发现文件已经删除了。",{"type":17,"tag":25,"props":675,"children":676},{},[677],{"type":23,"value":678},"此时我们再来删除文件夹",{"type":17,"tag":25,"props":680,"children":681},{},[682],{"type":23,"value":683},"git rm abc –r",{"type":17,"tag":25,"props":685,"children":686},{},[687],{"type":23,"value":688},"git commit –m “描述”",{"type":17,"tag":25,"props":690,"children":691},{},[692],{"type":23,"value":453},{"type":17,"tag":25,"props":694,"children":695},{},[696],{"type":17,"tag":143,"props":697,"children":700},{"alt":698,"src":699},"20200512-192207(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/1130272svk0eutc33uzoc6.png",[],{"type":17,"tag":25,"props":702,"children":703},{},[704],{"type":23,"value":705},"此时远程代码仓库刷新一下就会发现文件已经删除了。",{"type":17,"tag":621,"props":707,"children":709},{"id":708},"_2-找回文件",[710],{"type":23,"value":711},"2. 找回文件",{"type":17,"tag":25,"props":713,"children":714},{},[715],{"type":23,"value":716},"Git对于版本的管理本质是对提交的管理，所以再每个操作后最好提交一下，便于之后需要回退，例如要找回上面操作中删除的test1.txt。",{"type":17,"tag":25,"props":718,"children":719},{},[720],{"type":23,"value":721},"最重要的一点，如果你正在进行某些更改，需要先推送远程仓库，否则回退之后，最新的状态的内容就没有了。以如下流程为例子:",{"type":17,"tag":25,"props":723,"children":724},{},[725],{"type":23,"value":726},"Commit1—> Commit2--> Commit3(误删操作)--> Commit4--> Commit5(最新)",{"type":17,"tag":25,"props":728,"children":729},{},[730],{"type":23,"value":731},"我们先保存目前的Commit5，然后回退到Commit2，此时test1.txt出现了，但是最新变动没有了，我们拷贝出test1.txt。然后回退到Commit5，拷贝进去test1.txt，再推送到远程代码库，得到Commit6。",{"type":17,"tag":25,"props":733,"children":734},{},[735],{"type":23,"value":736},"执行命令：",{"type":17,"tag":25,"props":738,"children":739},{},[740],{"type":23,"value":741},"git log",{"type":17,"tag":25,"props":743,"children":744},{},[745],{"type":23,"value":746},"可以查看提交的唯一标识",{"type":17,"tag":25,"props":748,"children":749},{},[750],{"type":17,"tag":143,"props":751,"children":754},{"alt":752,"src":753},"20200512-194015(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/113121m2ppivt3okr8st8v.png",[],{"type":17,"tag":25,"props":756,"children":757},{},[758],{"type":23,"value":736},{"type":17,"tag":25,"props":760,"children":761},{},[762],{"type":23,"value":763},"git reset –hard 回退的commit唯一标识号",{"type":17,"tag":25,"props":765,"children":766},{},[767],{"type":23,"value":768},"拷贝出test1.txt",{"type":17,"tag":25,"props":770,"children":771},{},[772],{"type":23,"value":773},"git reset –hard 最新的commit唯一标识号",{"type":17,"tag":25,"props":775,"children":776},{},[777],{"type":23,"value":778},"拷贝test1.txt进本地代码库，push到远程代码仓库",{"type":17,"tag":25,"props":780,"children":781},{},[782],{"type":17,"tag":143,"props":783,"children":786},{"alt":784,"src":785},"20200512-194816(eSpace).png","https://bbs-img.huaweicloud.com/data/attachment/forum/202005/13/113316v3cxfg5kio28w6xt.png",[],{"type":17,"tag":25,"props":788,"children":789},{},[790],{"type":23,"value":791},"好啦，大功告成，此时的远程和本地代码仓库都已经恢复了test1.txt，但是没有恢复abc文件夹。",{"type":17,"tag":25,"props":793,"children":794},{},[795,797],{"type":23,"value":796},"通过上面的学习，已经基本掌握git+gitee的基础使用啦，每一个小甜头都是进步的动力，加油鸭！",{"type":17,"tag":143,"props":798,"children":800},{"alt":7,"src":799},"https://bbs.huaweicloud.com/forum/static/ueditor/dialogs/emotion/images/youa/y_0001.gif",[],{"title":7,"searchDepth":802,"depth":802,"links":803},4,[804,806,807],{"id":244,"depth":805,"text":244},2,{"id":280,"depth":805,"text":280},{"id":313,"depth":805,"text":313,"children":808},[809,811],{"id":623,"depth":810,"text":626},3,{"id":708,"depth":810,"text":711},"markdown","content:technology-blogs:zh:580.md","content","technology-blogs/zh/580.md","technology-blogs/zh/580","md",1776506138154]