IDEA git code has been committed, but not pushed, how to unsubmit the buffer code

Record that when I submitted the code, I slipped and committed redundant files by mistake, but did not push to the cloud, and wanted to withdraw the entire commit operation:

VCS–>Git–> Reset  HEAD on the idea menu bar …

 

 

At this time, select the method of rollback and which version to roll back to according to the figure, and click "Reset". In the "log" in "Version Control", the rollback is successful if the record of the latest submission disappears.

Off-topic extension
Among them: Reset Type
(1), Mixed is the default method. Only the source code is kept, and the commit and index information will be rolled back;
(2), Soft rolls back to a certain version. Only the commit information is rolled back, the code written before is still retained, and will not be restored to the index file level. If you still want to submit, just commit directly;
(3), Hard roll back completely, the local source code will also become the content of the previous version, and the code of the previous commit will not be retained.

For example:
Version 1: Add file a.txt, and write down the content "Version 1"
Version 2: Modify file a.txt, and add content, write down "Version 2"

On the basis of version 2, the b.txt file is added, and the content "version 3" is added (and git add), and then commit;

1. Use Mix to return to version 1:
the added b.txt file will turn into a red state (not git add state), indicating that this file is not controlled by git version tracking

2. Use the Soft method to return to version 1:
the added b.txt file will turn into a green state (the state of git add), indicating that this file is tracked and controlled by the git version

3. Return to version 1 in the Hard way:
all the contents of version 2 and version 3 disappear, leaving only the contents of version 1

You can undo the commit operation by using the Mix method or the Soft method, and at the same time reset the modified code to the uncommitted state, and re-commit it again.

Note: Both HEAD~ and HEAD^ are acceptable, and HEAD~1 is to undo the latest local submission; HEAD~ and HEAD~1 have the same meaning. HEAD~~ and HEAD^^ both refer to the next new version, that is, the third last version, and so on, and the numbers are the same.
 

Guess you like

Origin blog.csdn.net/weixin_50885665/article/details/131700707