Git常用操作之删除操作
Posted 取个名字真的很难
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Git常用操作之删除操作相关的知识,希望对你有一定的参考价值。
Git删除操作有两种
1.git rm
2.rm
有何不同?
git rm直接包含了add操作。show you the code
[email protected] /d/project/study (dev) $ git rm 2.txt rm ‘2.txt‘ [email protected] /d/project/study (dev) $ git status # On branch dev # Changes to be committed: # (use "git reset HEAD <file>..." to unstage) # # deleted: 2.txt # [email protected] /d/project/study (dev) $ git reset HEAD 2.txt Unstaged changes after reset: D 2.txt [email protected] /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") [email protected] /d/project/study (dev) $ git checkout 2.txt [email protected] /d/project/study (dev) $ git status # On branch dev nothing to commit, working directory clean
可以从上面的代码看出,当你执行了git rm操作后,已经是进入到暂存区的。
让我们看看rm操作的结果。
[email protected] /d/project/study (dev) $ rm 2.txt [email protected] /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") [email protected] /d/project/study (dev) $ git checkout 2.txt [email protected] /d/project/study (dev) $ git status # On branch dev nothing to commit, working directory clean
从上面可以看到,执行了rm操作后,是没有添加到暂存区的。依然是需要手动的去add。
以上是关于Git常用操作之删除操作的主要内容,如果未能解决你的问题,请参考以下文章
VSCode自定义代码片段15——git命令操作一个完整流程
VSCode自定义代码片段15——git命令操作一个完整流程