git mv与直接mv的区别
git mv
行为:
1.创建一个和之前文件内容一样的文件,文件名为新的文件名
2.将原来的文件删除
3.将删除的文件添加到暂存区
4.将新建的文件添加到暂存区
$ git mv a a1
$ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage)
renamed: a -> a1
提交:
直接 git commit -m ''
$ git commit -m 'rename a to a1'
[master 863356d] rename a to a1
1 file changed, 0 insertions(+), 0 deletions(-)
rename a => a1 (100%)
$ git status
On branch master
nothing to commit, working directory clean
恢复:
1. 恢复暂存区(git reset HEAD oldName)
2. 将新添加的文件从暂存区移除(git reset HEAD newName)
3. 将原来的文件从暂存区恢复到工作区(git checout -- oldName)
3. 从工作区删除新添加的这个文件(rm newName)
$ git reset HEAD a
Unstaged changes after reset:
D a $ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) new file: a1 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 $ git reset HEAD a1
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 Untracked files:
(use "git add <file>..." to include in what will be committed) a1 no changes added to commit (use "git add" and/or "git commit -a") $ git checkout -- a $ git status
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed) a1 nothing added to commit but untracked files present (use "git add" to track) $ rm a1 $ git status
On branch master
nothing to commit, working directory clean
直接调用系统的mv
行为:
只是重命名了一个文件
$ mv a a1 $ 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 Untracked files:
(use "git add <file>..." to include in what will be committed) a1 no changes added to commit (use "git add" and/or "git commit -a")
提交:
1.把新文件和旧文件加入暂存区
2.提交暂存区的改动
$ git add a a1 $ git status
On branch master
Changes to be committed:
(use "git reset HEAD <file>..." to unstage) renamed: a -> a1 $ git commit -m 'rename a to a1'
[master 8b02e6a] rename a to a1
file changed, insertions(+), deletions(-)
rename a => a1 (%) $ git status
On branch master
nothing to commit, working directory clean
恢复:
1.将旧文件恢复到工作区,git checout -- oldName
2.将新文件删除, rm newName
$ git checkout -- a
$ rm a1 $ git status
On branch master
nothing to commit, working directory clean
git mv与直接mv的区别的更多相关文章
- git 学习笔记5--rm & mv,undo
rm 删除文件 rm <file> #Unix删除文件 git rm <file> # git删除文件 git rm -f <file> # git强制删除文件 g ...
- git database 数据库 平面文件 Git 同其他系统的重要区别 Git 只关心文件数据的整体是否发生变化,而大多数其他系统则只关心文件内容的具体差异 Git 的设计哲学
小结: 1.如果要浏览项目的历史更新摘要,Git 不用跑到外面的服务器上去取数据回来 2.注意 git clone 应指定版本,它复制的这个版本的全部历史信息: 各个分支 git init 数据库 ...
- gitLab的使用 和 git 、 github、gitlab的区别
一.git . github.gitlab的区别 (百度相关内容得到的理解) 二.git最基本作用:版本控制 三.有集成了git的GIT安装包 github和gitlab都使用git该版 ...
- 关于git和SVN的介绍和区别
主要对git,svn进行一个简单的介绍. 顺带,我会在后面把我整理的一整套CSS3,PHP,MYSQL的开发的笔记打包放到百度云,有需要可以直接去百度云下载,这样以后你们开发就可以直接翻笔记不用百度搜 ...
- 浅谈Linux下mv和cp命令的区别
1.功能上的区别 mv:用户可以使用该命令为文件或目录重命名或将文件由一个目录移入另一个目录中. cp: 该命令的功能是将给出的文件或目录拷贝到另一文件或目录中. 2.从inode角度来区分 mv:会 ...
- 对比git rm和rm的使用区别
在这里说一下git rm和rm的区别,虽然觉得这个问题有点肤浅,但对于刚接触git不久的朋友来说还是有必要的. 用 git rm 来删除文件,同时还会将这个删除操作记录下来:用 rm 来删除文件,仅仅 ...
- git和其他版本控制系统的区别
所有除了Git以外的版本控制系统都使用增量存储方式来保存不同版本,而Git则在每一个commit时,保存一个整个文件的content copy,除非那个文件没有做过改动.Git和其他版本系统的主要区别 ...
- git commit -m与-am的区别
前面的话 使用git commit -am是不是就可以完全不使用git add命令呢?不是 理论 要了解git commit -m与git commit -am的区别,首先要明白它们的定义 字面解释的 ...
- Git分支merge和rebase的区别
Git merge是用来合并两个分支的. git merge b # 将b分支合并到当前分支 同样 git rebase b,也是把 b分支合并到当前分支 原理 如下: 假设你现在基于远程分支&quo ...
随机推荐
- QT 5.7.0 移植之 tslib 编译配置
QT5.7 编译请参考:http://www.cnblogs.com/chenfulin5/p/5798764.html 最新的 tslib 是从他的 github 下载下来的. 地址是:https: ...
- [Busybox]Busybox制作文件系统
问题: 1.目前busybox和bootstrap两种方案制作文件系统,哪种开发周期更短,更加简单? 2.如果需要在文件系统中添加某个package,要怎么做,如vim/udhcpd等? 转自:htt ...
- jquery设置radio选中
<script type="text/javascript"> $(document).ready(function(){ $("input[type=rad ...
- asp.net 简单分页打印
<html> <head> <title>看看</title> <meta http-equiv="Content-Type" ...
- Golang 中操作 Mongo Update 的方法
Golang 和 MongoDB 中的 ISODate 时间交互问题 2018年02月27日 11:28:43 独一无二的小个性 阅读数:357 标签: GolangMongoDB时间交互时间转换 更 ...
- java--Struts中请求的过程
一个请求在Struts2框架中的处理步骤: a) 客户端初始化一个指向Servlet容器的请求: b) 根据Web.xml配置,请求首先经过ActionContextCleanUp过滤器,其为可选过滤 ...
- annexb模式
h264有两种封装,一种是annexb模式,传统模式,有startcode,SPS和PPS是在ES中一种是mp4模式,一般mp4 mkv会有,没有startcode,SPS和PPS以及其它信息被封装在 ...
- 【BZOJ】1638: [Usaco2007 Mar]Cow Traffic 奶牛交通(dfs+dp)
http://www.lydsy.com/JudgeOnline/problem.php?id=1638 一条边(u, v)经过的数量=度0到u的数量×v到n的数量 两次记忆化dfs算出他们即可 #i ...
- VC++:ActiveX Test Container
VC++6.0安装后包含了ActiveX Test Container工具,位置为: "C:\Program Files (x86)\Microsoft Visual Studio\Comm ...
- 编程之美 set 9 字符串移位包含问题
题目 给定字符串 s1 和 s2, 要求判定 s2能否能够被通过 s1 做循环移位得到的字符包含. s1 = AABCD, s2 = CDAA 返回 true. 给定 s1 = ABCD 和 s2 = ...