其他分享
首页 > 其他分享> > git restore 和 git restore --staged的区别

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

标签:restore,git,--,sps,code,master,5130
来源: https://www.cnblogs.com/circle-coder/p/15709482.html