简体   繁体   中英

How can I (simply) undo changes to a file in GIT?

lets say I have a file, and lets call it "A.java".

....I don't have any hash tag ids / etc... I just want to go back to the file in the state before I screwed it up .

git reset --hard will reset all files in the repository back to their state. git checkout A.java will reset just that file.

git checkout -- <filename>

this will checkout your file to the master repository.

Check this out for more information

Difference between "git checkout <filename>" and "git checkout -​- <filename>"

git checkout -- A.java
git pull #if you need to pull changes from the remote.

This assumes you haven't already tried to pull and are in the middle of a merge.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM