• git恢复idea中被误删除的文件


    $ git status
    
    On branch master
    
    Your branch is up-to-date with 'origin/master'.
    
    
    Changes to be committed:
    
    (use "git reset HEAD <file>..." to unstage)
    
    
    deleted: mybatis-06/src/main/java/com/rui/dao/TeacherMapper.java
    
    deleted: mybatis-06/src/main/java/com/rui/pojo/Student.java
    
    deleted: mybatis-06/src/main/java/com/rui/pojo/Teacher.java
    
    deleted: mybatis-06/src/main/java/com/rui/utils/MyBatisUtils.java
    
    deleted: mybatis-06/src/main/resources/com/rui/dao/StudentMapper.xml
    
    deleted: mybatis-06/src/main/resources/com/rui/dao/TeacherMapper.xml
    
     
    
    Changes not staged for commit:
    
    (use "git add/rm <file>..." to update what will be committed)
    
    (use "git checkout -- <file>..." to discard changes in working directory)
    
     
    
    modified: mybatis-01/target/classes/com/rui/dao/UserMapper.xml
    
    modified: mybatis-01/target/classes/mybatis-config.xml
    
    modified: mybatis-02/target/classes/mybatis-config.xml
    
    modified: mybatis-03/target/classes/com/rui/dao/UserMapper.xml
    
    deleted: mybatis-06/src/main/java/com/rui/dao/StudentMapper.java
    
    modified: mybatis-07/target/classes/com/rui/dao/StudentMapper.class
    
    modified: mybatis-07/target/classes/com/rui/dao/TeacherMapper.class
    
    modified: mybatis-07/target/classes/com/rui/dao/TeacherMapper.xml
    
    modified: mybatis-07/target/classes/com/rui/pojo/Student.class
    
    modified: mybatis-07/target/classes/com/rui/pojo/Teacher.class
    
    modified: mybatis-07/target/classes/com/rui/utils/MyBatisUtils.class
    
    modified: mybatis-07/target/classes/db.properties
    
    modified: mybatis-07/target/test-classes/com/rui/MyTest.class
    
    modified: "mybatis\347\254\224\350\256\260/Mybatis\347\254\224\350\256\260.md"
    
    
    Untracked files:
    
    (use "git add <file>..." to include in what will be committed)
    
    
    .idea/
    
    MyBatis-Study.iml
    
    mybatis-01/mybatis-01.iml
    
    mybatis-02/mybatis-02.iml
    
    mybatis-03/mybatis-03.iml
    
    mybatis-04/log/log4j-DEBUG.log
    
    …
    
    原因很清楚,按照提示进行reset和checkout操作即可。具体原因,git的工作区-暂存区-本地仓库和远程仓库四者的关系已经很清楚,如下图
    
    三、解决方法
    1.打开git bash,这个才是底层。
    
    2.进入需要恢复目录,运行reset命令
    
    $ git reset .
    Unstaged changes after reset:
    D mybatis-06/src/main/java/com/rui/dao/TeacherMapper.java
    D mybatis-06/src/main/java/com/rui/pojo/Student.java
    D mybatis-06/src/main/java/com/rui/pojo/Teacher.java
    D mybatis-06/src/main/java/com/rui/utils/MyBatisUtils.java
    D mybatis-06/src/main/resources/com/rui/dao/StudentMapper.xml
    D mybatis-06/src/main/resources/com/rui/dao/TeacherMapper.xml
    3.运行checkout
    
    $ git checkout .
    即可恢复
    
    五、参考
    1.https://www.iteye.com/blog/josh-persistence-2215214
    
    2.http://disinuo.me/2016/12/12/2016-12-12-git_note/
    

      

  • 相关阅读:
    learning hdmi edid protocol
    得到本地应用程序的EXE的路径
    获取系统特殊文件夹路径
    判断计算机的联机状态
    判断计算机是否连接网络
    得到本地机器的IP地址
    获取屏幕分辨率
    获取声音设备名称
    获取显示设备的名称及PNPDeviceID
    判断驱动器类型并获其属性
  • 原文地址:https://www.cnblogs.com/zhanglanzuopin/p/15850057.html
Copyright © 2020-2023  润新知