git版本回退操作(基于idea方式) 您所在的位置:网站首页 idea中git回退到上一次提交 git版本回退操作(基于idea方式)

git版本回退操作(基于idea方式)

2024-07-10 13:35| 来源: 网络整理| 查看: 265

1、undo commit

undo commit 操作,删除此次提交记录,工作区会保留修改。

说明: idea中的undo commit,本质是利用 git reset 命令实现的。如下:

git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --soft 4990bcf17465705a66326e1698f72c63ee2c214e 2、revert commit

revert commit 操作,不删除提交记录,会新增一条提交记录。

说明: idea中的revert commit,本质是利用 git revert 命令实现的。如下:

git -c credential.helper= -c core.quotepath=false -c log.showSignature=false revert 48b049f299cad6e82045dd3a48ca9e14b86a06fa --no-commit 3、drop commit

drop commit 操作,删除提交记录,工作区不会保留修改。

说明: idea中的drop commit,本质是利用 git rebase 命令实现的。如下:

git -c credential.helper= -c core.quotepath=false -c log.showSignature=false -c core.commentChar= rebase --interactive --no-autosquash 4990bcf17465705a66326e1698f72c63ee2c214e 4、reset current branch to here

reset current branch to here 操作,有四种选项,分别是soft、mixed、keep、hard。

说明: Soft 模式:回滚到指定版本,并保留所有更改,这些更改将被重新提交。使用这种模式,你可以撤销已经提交的更改,然后重新提交。

Mix 模式:回滚到指定版本,并保留所有更改,但是更改将不会被重新提交。使用这种模式,你可以撤销已经提交的更改,并保留这些更改,以备后续修改和提交。

Keep 模式:回滚到指定版本,但是保留指定版本之后的更改。使用这种模式,你可以撤销指定版本之后的更改,并保留这些更改,以备后续修改和提交。

Hard 模式:回滚到指定版本,并删除指定版本之后的所有更改。使用这种模式,你可以完全撤销指定版本之后的所有更改。

总结: 四种选项模式,本质都是git reset 命令实现的。如下:

reset current branch to here --soft git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --soft 4990bcf17465705a66326e1698f72c63ee2c214e reset current branch to here --mixed git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --mixed 4990bcf17465705a66326e1698f72c63ee2c214e reset current branch to here --keep git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --keep 4990bcf17465705a66326e1698f72c63ee2c214e reset current branch to here --hard git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --hard 4990bcf17465705a66326e1698f72c63ee2c214e 5、reset head

reset head 操作,也有三种选项,分别是soft、mixed、hard。

说明: Soft 模式:回滚到指定版本,并保留所有更改,这些更改将被重新提交。使用这种模式,你可以撤销已经提交的更改,然后重新提交。

Mix 模式:回滚到指定版本,并保留所有更改,但是更改将不会被重新提交。使用这种模式,你可以撤销已经提交的更改,并保留这些更改,以备后续修改和提交。

Hard 模式:回滚到指定版本,并删除指定版本之后的所有更改。使用这种模式,你可以完全撤销指定版本之后的所有更改。

总结: 以上三种选项模式,本质都是git reset 命令实现的。如下:

reset head --soft git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --soft 4990bcf17465705a66326e1698f72c63ee2c214e reset head --mixed git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --mixed 4990bcf17465705a66326e1698f72c63ee2c214e reset head --hard git -c credential.helper= -c core.quotepath=false -c log.showSignature=false reset --hard 4990bcf17465705a66326e1698f72c63ee2c214e


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有