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

在这里插入图片描述

  • 18
    点赞
  • 28
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
PyCharm撤回commit有几种方法可以选择。首先,你可以使用Git的撤销功能来撤回commit。在PyCharm中,你可以通过以下步骤来实现: 1. 打开Git工具窗口,可以通过按下Alt + 9来打开。 2. 在Git工具窗口中,找到你想要撤回commit,并右键点击它。 3. 在弹出的菜单中选择"Undo Commit"选项。如果你的commit已经push到远程仓库,这个选项可能不可用。 4. 确认撤销commit,并重新提交你的更改。 另外,如果你想要撤回commit不是最后一次提交的版本,并且希望保留后续提交的版本,你可以使用git revert命令。在PyCharm中,你可以通过以下步骤来实现: 1. 打开Git工具窗口,并找到你想要撤回commit的版本号。你可以使用git log命令来查看版本号。 2. 在Git工具窗口中,使用git revert命令来撤回commit。例如,如果你想要撤回上次提交的代码,可以使用命令"git revert HEAD"。如果你想要撤回之前的某个版本,可以使用命令"git revert \[commit id\]",其中\[commit id\]是你想要撤回的版本的ID。 总之,PyCharm提供了多种方法来撤回commit,你可以根据你的需求选择适合你的方法。 #### 引用[.reference_title] - *1* [pycharm怎么撤回已经commitpush)的文件](https://blog.csdn.net/prolrj2015/article/details/90371098)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *2* [pycharmcommit/push撤销+分支合并](https://blog.csdn.net/qq_38230414/article/details/128698493)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] - *3* [Git代码提交和撤回](https://blog.csdn.net/weixin_40283460/article/details/109683826)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值