关于pycharm撤回已经commit(未push)的文件

官网如是:

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的文件即可。

原文地址:https://www.cnblogs.com/tu240302975/p/12934519.html