首页 > 其他 > 详细

Git常用操作之删除操作

时间:2017-10-26 21:38:52      阅读:224      评论:0      收藏:0      [点我收藏+]

Git删除操作有两种

1.git rm 

2.rm

有何不同?

git rm直接包含了add操作。show you the code

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git rm 2.txt
rm ‘2.txt‘

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git status
# On branch dev
# Changes to be committed:
#   (use "git reset HEAD <file>..." to unstage)
#
#       deleted:    2.txt
#

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git reset HEAD 2.txt
Unstaged changes after reset:
D       2.txt

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git status
# On branch dev
# 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:    2.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git checkout 2.txt

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git status
# On branch dev
nothing to commit, working directory clean

  可以从上面的代码看出,当你执行了git rm操作后,已经是进入到暂存区的。

让我们看看rm操作的结果。

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ rm 2.txt

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git status
# On branch dev
# 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:    2.txt
#
no changes added to commit (use "git add" and/or "git commit -a")

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git checkout 2.txt

bocur@DESKTOP-PTRIQEA /d/project/study (dev)
$ git status
# On branch dev
nothing to commit, working directory clean

  从上面可以看到,执行了rm操作后,是没有添加到暂存区的。依然是需要手动的去add。

 

Git常用操作之删除操作

原文:http://www.cnblogs.com/bocurry/p/7739291.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!