您当前的位置: 首页 > 学无止境 > 心得笔记 网站首页心得笔记
23 怎样取消暂存区部分文件的...
发布时间:2020-07-19 09:24:04编辑:雪饮阅读()
首先我们来看看我们目前暂存区所有文件都是已暂存,且文件列表如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/we5 (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: 1.txt
modified: 2.txt
modified: 3.txt
之前曾经说过用reset可以将暂存区还原到head状态,而之前讲的是整个暂存区的还原,那么如果我只想还原指定文件呢?只需要指定文件名即可,如这里仅将1.txt还原
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/we5 (master)
$ git reset HEAD -- 1.txt
Unstaged changes after reset:
M 1.txt
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/we5 (master)
$ git status
On branch master
Changes to be committed:
(use "git restore --staged <file>..." to unstage)
modified: 2.txt
modified: 3.txt
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: 1.txt
那么如果我想要同时还原多个文件呢?可以这样做,如
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/we5 (master)
$ git reset HEAD -- 2.txt 3.txt
Unstaged changes after reset:
M 1.txt
M 2.txt
M 3.txt
xy@DESKTOP-BG9HNHK MINGW64 ~/Desktop/web/we5 (master)
$ git status
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: 1.txt
modified: 2.txt
modified: 3.txt
no changes added to commit (use "git add" and/or "git commit -a")
关键字词:git,暂存区,取消,head,局部,部分
下一篇:24 消除最近的几次提交