Git如何撤銷本地所有的更改操作還原到更改前的代碼?


非常簡單,只需要一個命令(*號代表所有更改的文件):

git checkout -- *

例如:

D:\gitee\xxl-api>git status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

        modified: xxl-api-admin/src/main/java/com/xxl/api/admin/controller/XxlApiBizController.java
        modified:   xxl-api-admin/src/main/java/com/xxl/api/admin/core/model/XxlApiBiz.java
        modified:   xxl-api-admin/src/main/java/com/xxl/api/admin/core/util/ThrowableUtil.java
        modified:   xxl-api-admin/src/main/resources/application.properties 
no changes added to commit (use "git add" and/or "git commit -a")

D:\gitee\xxl-api>git checkout -- *

D:\gitee\xxl-api>git status
On branch master
Your branch is up to date with 'origin/master'.

nothing to commit, working tree clean

 


免責聲明!

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



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