一图顶千言
1. 工作区内容有修改,还没有add,如果想撤销修改,用命令
git restore <file>...
On branch master
Changes not staged for commit:
(use "git add <file>..." to update what will be committed)
(use "git restore <file>..." to discard changes in working directory)
modified: 71.txt
2. 工作区内容有修改,并且add 进入了暂存区,想撤销修改
先用
git restore --staged 71.txt
这样回到工作区
再用
git restore <file>...
3. 工作区间内容有变化,并且没有add ,如何删除
On branch master
Untracked files:
(use "git add <file>..." to include in what will be committed)
8.txt
git clean 谨慎使用
git clean --->移除工作区的改动、新增、删除
git clean -f <path>
删除指定路径下的没有被track过的文件
git clean -df
删除当前目录下没有被track过的文件和文件夹
使用过程如下所示:
git clean -df
Removing 8.txt
git status
On branch master
nothing to commit, working tree clean