git checkout -- xx error

Want to use the git checkout -- UserDaoTest.java command to replace the code in the version area with the code in the workspace

Using git checkout -- UserDaoTest.java I got the following error:

error: pathspec 'UserDaoTest.java' did not match any file(s) known to git.

 

 The reason is that UserDaoTest.java has been placed in the cache area, so it cannot be matched in the version area

Solution:

1. git rest HEAD UserDaoTest.java will revoke the code in the cache area

 

Unstaged changes after reset:

 

D       src/main/java/UserDaoTest.java

 

2. git checkout -- UserDaoTest.java  replaces the code in the version area with the code in the workspace

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326480720&siteId=291194637