git rm

行为:

  1.删除一个文件

  2.将被删除的这个文件纳入缓存区

$ git rm a
rm 'a'
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) deleted: a

提交:

  直接 git commit -m ''

$ git commit -m 'delete a'
[master 1cd6efe] delete a
file changed, insertions(+), deletions(-)
delete mode a $ git status
On branch master
nothing to commit, working directory clean

恢复:

  1. 恢复暂存区

  2. 恢复工作区

$ git reset HEAD a
Unstaged changes after reset:
D a $ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) deleted: a no changes added to commit (use "git add" and/or "git commit -a") $ git checkout -- a
$ git status
On branch master
nothing to commit, working directory clean

直接调用系统的rm

行为:

  从工作区删除了一个文件

$ rm a

$ git status
On branch master
Changes not staged for commit:
(use "git add/rm <file>..." to update what will be committed)
(use "git checkout -- <file>..." to discard changes in working directory) deleted: a no changes added to commit (use "git add" and/or "git commit -a")

提交:

  1.把修改加入暂存区

  2.提交暂存区的改动

$ git add a

$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) deleted: a $ git commit -m 'delete a '
[master 689a73d] delete a
file changed, insertions(+), deletions(-)
delete mode a $ git status
On branch master
nothing to commit, working directory clean

恢复:

  直接恢复工作区就好了,git checout -- file

$ git checkout -- a

$ git status
On branch master
nothing to commit, working directory clean

  

git rm与直接rm的区别的更多相关文章

  1. [git] 细说commit (git add/commit/diff/rm/reset 以及 index 的概念)

    http://kasicass.blog.163.com/blog/static/39561920133294219374/ 创建测试仓库 $ git init $ echo "line o ...

  2. git mv与直接mv的区别

    git mv 行为: 1.创建一个和之前文件内容一样的文件,文件名为新的文件名 2.将原来的文件删除 3.将删除的文件添加到暂存区 4.将新建的文件添加到暂存区 $ git mv a a1 $ git ...

  3. [rm] Linux 防止"rm -rf /" 误删除

    一.缘由: 最近看到这则新闻,很是悲伤,因为我最近也在用ansible:然而这一错误源自Ansible上糟糕的代码设计,这款Linux实用工具被用于在多台不同服务器上自动执行脚本. 开发者解释到,实际 ...

  4. git database 数据库 平面文件 Git 同其他系统的重要区别 Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异 Git 的设计哲学

    小结: 1.如果要浏览项目的历史更新摘要,Git 不用跑到外面的服务器上去取数据回来 2.注意 git clone  应指定版本,它复制的这个版本的全部历史信息: 各个分支  git init 数据库 ...

  5. gitLab的使用 和 git 、 github、gitlab的区别

    一.git . github.gitlab的区别  (百度相关内容得到的理解) ​ ​ 二.git最基本作用:版本控制 ​ 三.有集成了git的GIT安装包 github和gitlab都使用git该版 ...

  6. 关于linux shell编程,alias rm='cp $@ ~/backup; rm $@'

    书上的这个例子需要在ubuntu的低版本的系统才支持,现在基本上都不支持了,想实现也很简单自己写一个脚本先备份再删除. alias也只是做了一次替换alias rm='cp $@ ~/backup; ...

  7. 关于git和SVN的介绍和区别

    主要对git,svn进行一个简单的介绍. 顺带,我会在后面把我整理的一整套CSS3,PHP,MYSQL的开发的笔记打包放到百度云,有需要可以直接去百度云下载,这样以后你们开发就可以直接翻笔记不用百度搜 ...

  8. git 常用命令 mv rm checkout revert reset

    关于上节讲的git add 时需要添加注释信息,也可以在git commit时再添加 laoni@DESKTOP-TPPLHIB MINGW64 /c/laoni/PycharmProjects/gi ...

  9. git和其他版本控制系统的区别

    所有除了Git以外的版本控制系统都使用增量存储方式来保存不同版本,而Git则在每一个commit时,保存一个整个文件的content copy,除非那个文件没有做过改动.Git和其他版本系统的主要区别 ...

随机推荐

  1. 蓝牙(CoreBluetooth)-概述

    蓝牙(CoreBluetooth)-概述 通过此框架可以让你的Mac和iOS应用程序与外部蓝牙设备通信 外部设备: 就是需要通过iOS App控制器的其他设备: 例如:心率检测仪.数字温控器 蓝牙通讯 ...

  2. font-sqirrel

    html5之前,只要稍微特殊点的字体,都必须做成图片,以免客户端无法显示.而对于正文或者需要后台调用大量文字的地方,则无能为力.但是,html5推出了 @font-face 支持自定义字体之后,这个问 ...

  3. dirname(__FILE__) 的使用总结 1(转)

    dirname(__FILE__) php中定义了一个很有用的常数,即 __file__ 这个内定常数是当前php程序的就是完整路径(路径+文件名). 即使这个文件被其他文件引用(include或re ...

  4. IT 服务管理工具 iTop

    iTop,作为全面支持ITIL流程的一款ITSM工具,具有强大的ITSM功能,开源免费.简单易用. iTop,即IT运营门户(IT Operation Portal),是一个开源web应用程序,用于I ...

  5. nginx中,$request_uri和$uri的区别

    nginx中,$request_uri和$uri的区别   $request_uri This variable is equal to the *original* request URI as r ...

  6. swt生成、jar可执行包生成.exe可执行文件(giter)

    http://tomfish88.iteye.com/blog/1074786 —————————————————————————————————————————————————————————— 最 ...

  7. va_list中的_vsntprintf使用介绍

    相信大家都用过sprintf这个函数,就是下面这样: int sprintf( char *buffer, const char *format [, argument] ... ); 在之前看到了用 ...

  8. CSS Transform / Transition / Animation 属性的区别

    back21 Jun 2011 Category: tech Tags: css 最近想UI的动画转到css3能吃进3d加速的属性上面来以加强动画的连贯性.只是对于css几个新加的属性不太熟悉,常常容 ...

  9. JQ实现吸顶效果代码

    吸顶下过代码跟简单几行代码就可以了 如果滚动的军力大于100,就改变导航的定位方式,否则就默认 $(function(){         $(window).scroll(function(){   ...

  10. 什么是 GOF(四人帮,全拼 Gang of Four)?

    在 1994 年,由 Erich Gamma.Richard Helm.Ralph Johnson 和 John Vlissides 四人合著出版了一本名为 Design Patterns - Ele ...