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. CSU 1329: 一行盒子

    1329: 一行盒子 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 740  Solved: 145[Submit][Status][Web Board ...

  2. Jquery js框架使用

    jquery  众所周知 ,强大的 js框架 自己使用的一些笔记 //1.json格式定义方法 var product_obj={    check_init:function(){          ...

  3. (译)Getting Started——1.2.1 Defining the Concept(确定理念)

    每个出色的应用都是由理念开始的.在开发应用时,你不需要把理念完善和完成后再进行开发.但是你确实需要确定你要做什么,做完后的效果如何. 为了定义理念,问自己以下的问题: 应用的受众是哪些人?应用的内容和 ...

  4. lua工具库penlight--06数据(一)

    这篇太长了,分了两部分.(这个是机器翻译之后我又校对了一下,以后的都这样,人工翻译太累了.) 读数据文件 首先考虑清楚,你的确需要一个自定义的文件读入器吗?如果是,你能确定有能力写好吗? 正确,稳健, ...

  5. hive export import命令

    EXPORT TABLE stu_p TO 导入表(必须明白导出表,导出表是将表的元数据,数据导出到hdfs上.)讲一个导出的表导入到数据库中,这个hdfs_path 是一个导出表的文件夹 impor ...

  6. 由Python的一个小例子想到的

    习题: L = [1,2] L.append(L) Print L 问,结果是什么. 结果是,[1,2,[...]] 这是什么意思呢?就是说[...]表示的对[1,2]的无限循环.这一点是在C#等静态 ...

  7. java.lang.IllegalArgumentException: n must be positive

    public static String randomKey(){ Random random = new Random(); int key = random.nextInt(((int)Syste ...

  8. CentOS平滑升级Nginx

    服务器:CentOS 6.4 64位 升级方案:nginx1.4.0 – nginx1.4.3 Nginx编译后就一个小文件,不带动态库,升级也可以无缝升级,并不影响访问,按下面的命令执行就可以,具体 ...

  9. 爬虫(2)- HTTP和HTTPS 相关知识

    HTTP和HTTPS HTTP协议(HyperText Transfer Protocol,超文本传输协议):是一种发布和接收 HTML页面的方法. HTTPS(Hypertext Transfer ...

  10. 使用AllocConsole()添加调试用控制台

    AllocConsole 函数 为调用进程分配一个新的控制台. 使用步骤: 1. AllocConsole(); //分配控制台 2. HANDLE  g_hOutput=GetStdHandle( ...