官網如是:
https://www.jetbrains.com/help/pycharm/undo-changes.html
Undo the last commit
PyCharm allows you to undo the last commit in the current branch (i.e. HEAD):
Open the Version Control tool window (Alt+9) and switch to the Log tab.
Select the last commit in the current branch and choose Undo Commit from the context menu.
In the dialog that opens, select a changelist where the changes you are going to discard will be moved. You can either select an existing changelist from the Name drop-down list, or specify the name of a new changelist (the commit message is used by default).
Select the Set active option if you want to make the changelist with the changes you are about to discard the active changelist.
Select the Track context option if you want PyCharm to remember your context and reload currently opened files in the editor when this changelist becomes active.
You cannot undo a commit if it was pushed to a protected branch, i.e. a branch to which force --push is not allowed (configure protected branches in the Settings/Preferences dialog (Ctrl+Alt+S) under Version Control | Git).
其實說的已經很清楚了。這里加一張圖說明吧:
撤回操作
首先alt + 9 >> log >> 右鍵你想要撤回的那一條 >> Undo Commit
看到Undo Commit >> 我這個是已經push的了,如果你的commit了但是還沒有push這里並不是灰色的。如果你想撤銷就點擊這個。
重新提交commit
ctrl + K >> 在changelist中選擇剛才撤回的那個commit message項,就會出現剛才commit的所有文件 >> 此時選擇你這次想要commit的文件即可。