Git reset --hard After rolling back/rolling back to the previous version of the code, I regret it, how to simply organize the method after restoring the version

Git reset --hard After rolling back/rolling back to the previous version of the code, I regret it, how to simply organize the method after restoring the version

Table of contents

Git reset --hard After rolling back/rolling back to the previous version of the code, I regret it, how to simply organize the method after restoring the version

1. Brief introduction

2. Operation steps

1. View commit log records

 2. Now simulate the rollback/rollback version to "modify data.txt file"

3. Roll back/roll back the version to "Modify data.txt file"

 4. I regret it now, and want to go back to the later version "modify data.txt copywriting" commit

5. But neither git log nor gitk can display the version "modify data.txt copywriting"

 6. At this point, you can use git reflog to view all commit log records (including after reset --hard)

7. Then use git reset --hard again to return to the version "modify data.txt copywriting"

8. Check git log and gitk, you can see that it has returned to the original version


1. Brief introduction

Git (pronounced /gɪt/.) is an open source distributed version control system that can effectively and quickly handle project version management from small to very large. [1] Git is an open source version control software developed by Linus Torvalds to help manage Linux kernel development.

This section introduces that after Git's reset --hard rolls back/rolls back to the previous version code, it may be necessary to restore the rollback/rollback version due to impulse. Here is a simple way to sort out the rollback method. If there are deficiencies , welcome to point out, or if you have a better method, please leave a message.

2. Operation steps

1. View commit log records

Command: git log

 2. Now simulate the rollback/rollback version to "modify data.txt file"

3. Roll back/roll back the version to "Modify data.txt file"

Command: git reset --hard xxxx

 4. I regret it now, and want to go back to the later version "modify data.txt copywriting" commit

 

5. But neither git log nor gitk can display the version "modify data.txt copywriting"

 6. At this point, you can use git reflog to view all commit log records (including after reset --hard)

Command: git reflog

7. Then use git reset --hard again to return to the version "modify data.txt copywriting"

8. Check git log and gitk, you can see that it has returned to the original version

 

 Regret medicine can be taken, but usually pay more attention

Guess you like

Origin blog.csdn.net/u014361280/article/details/127740356