git restore 和 git restore --staged的区别

git restore --staged 将文件从暂存区撤回工作区
git restore 将在工作区的文件撤销更改

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$  echo "Hello Git" >> hello.txt 

sps-5130@sps-5130 MINGW64 /d/code/gitrep (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:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$ git add hello.txt 
warning: LF will be replaced by CRLF in hello.txt.
The file will have its original line endings in your working directory

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$ git status
On branch master
Changes to be committed:
  (use "git restore --staged <file>..." to unstage)
        modified:   hello.txt

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$ git restore --staged hello.txt

sps-5130@sps-5130 MINGW64 /d/code/gitrep (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:   hello.txt

no changes added to commit (use "git add" and/or "git commit -a")

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$ git restore hello.txt

sps-5130@sps-5130 MINGW64 /d/code/gitrep (master)
$ git status
On branch master
nothing to commit, working tree clean
上一篇:oco2dx-2d仿3d动画grid3d


下一篇:php服务器端向前台js客户端传递特征字符处理