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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM