git tip: How to undo an uncommitted change/deletion for a specific file in your working directory

来源:互联网 发布:js escape替代方法 编辑:程序博客网 时间:2024/06/05 07:42

Imagine you are in a situation: You deleted/modified a file, then before you commit, you realized you it was a bad idea to delete / to make changes to that file. you do not want to commit that deletion/change, in other words, you want the file to go back to the same status as you last pulled from the remote repo. Other than finding the file back from the recycle bin, you can use

git checkout -- your/file/name

to discard changes you made to a specific file in your working directory. Also, the wild card works here, too. Use

git checkout -- *

to remove all changes made to unstaged files that are listed by

git status


0 0
原创粉丝点击