How git restores all changes
This article mainly explains "how git restores all modifications". The explanation content in this article is simple and clear, easy to learn and understand. Please follow the idea of Xiaobian slowly and deeply to study and learn "how git restores all modifications" together!
Methods: 1. Restore the file with the command "git checkout--file" when there is no git operation;2. Restore the current version with the command "git reset HEAD" when the file is submitted to the temporary storage area;3. Restore the previous version with the command "git reset HEAD^" when the file is submitted to the warehouse area.
Operating environment: Windows 10 system, Git version 2.30.0, Dell G3 computer.
How does git restore all changes
There are three types of reduction:
Just modify the file, no git operation
Modified file and submitted to staging area (i.e. git add without git commit -m "comment xxx" after editing)
Modified the file and submitted it to the repository (i.e. after editing, git add and git commit -m "comment xxx")
If Case 1:
git checkout --a. html//specify restore `aaa.html` files git checkout -- * //restore all files
If Case 2:
git log --oneline //git reset HEAD can be omitted //fallback to current version git checkout --a.html
If it is case 3:
git log --oneline //git reset HEAD^can be omitted //Go back to the previous version, note that there is a ^HEAD^behind HEAD is to go back to the previous version HEAD^^is to go back to the previous version HEAD~ the number is to go back to the number version git checkout -- aaa.html Thank you for reading, the above is the content of "how to restore all modifications", after studying this article, I believe everyone has a deeper understanding of how to restore all modifications to git. The specific use situation still needs to be verified by practice. Here is, Xiaobian will push more articles related to knowledge points for everyone, welcome to pay attention!