自己写了代码想要回滚,之前自己的方法太耽误时间了,同事教了一个方法可以快速回滚
第一部分:回滚:点击history-->Version Control-->log
同时选中两个版本-->
2、然后回滚;
第二部分提交区
git 有四个区域,1、编辑区,2、暂存区 3、待提交区 4、提交区
1、git status 看一下当前的状态:
mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支与上游分支 'origin/feature/20210119_8832954_fixed_guid_1' 一致。 尚未暂存以备提交的变更: (使用 "git add <文件>..." 更新要提交的内容) (使用 "git restore <文件>..." 丢弃工作区的改动) 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/BizMzEventChannelService.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/impl/BizMzEventChannelServiceImpl.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/price/serivce/impl/BizMzPriceServiceImpl.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizMzPriceServiceMockTest.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizPriceServiceTest.java 未跟踪的文件: (使用 "git add <文件>..." 以包含要提交的内容) pms/pms-web/application.pid pms/pms-web/bdbtmp/ pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java 修改尚未加入提交(使用 "git add" 和/或 "git commit -a")
然后 输入 2、git add. (注意后面有个点.)
将编辑器放到暂存区
3、git status 发现很多的新的文件,不需要提交的,直删除
4、删除完了在执行:git add.
git status;
5、
git commit -m 'rollback' (这里-m中间没有空格)
这是将文件从暂存区到待提交区;
git status
6、push 到服务端:
git push
最后面有如何回滚的代码示例
mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支与上游分支 'origin/feature/20210119_8832954_fixed_guid_1' 一致。 尚未暂存以备提交的变更: (使用 "git add <文件>..." 更新要提交的内容) (使用 "git restore <文件>..." 丢弃工作区的改动) 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/BizMzEventChannelService.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/impl/BizMzEventChannelServiceImpl.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/price/serivce/impl/BizMzPriceServiceImpl.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizMzPriceServiceMockTest.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizPriceServiceTest.java 未跟踪的文件: (使用 "git add <文件>..." 以包含要提交的内容) pms/pms-web/application.pid pms/pms-web/bdbtmp/ pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java 修改尚未加入提交(使用 "git add" 和/或 "git commit -a") ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git add . ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支与上游分支 'origin/feature/20210119_8832954_fixed_guid_1' 一致。 要提交的变更: (使用 "git restore --staged <文件>..." 以取消暂存) 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/BizMzEventChannelService.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/impl/BizMzEventChannelServiceImpl.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/price/serivce/impl/BizMzPriceServiceImpl.java 新文件: pms/pms-web/application.pid 新文件: pms/pms-web/bdbtmp/1604062647928158508617requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1604062647928158508617requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1604062647928158508617requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1604062647928158508617requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1604065267957-471726803requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1604065267957-471726803requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1604065267957-471726803requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1604065267957-471726803requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16040686174281834278468requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16040686174281834278468requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16040686174281834278468requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16040686174281834278468requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16040698665182142304853requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16040698665182142304853requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16040698665182142304853requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16040698665182142304853requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1604071818154-350741446requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1604071818154-350741446requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1604071818154-350741446requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1604071818154-350741446requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1604305295482-174376996requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1604305295482-174376996requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1604305295482-174376996requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1604305295482-174376996requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1604308919788-1448182593requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1604308919788-1448182593requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1604308919788-1448182593requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1604308919788-1448182593requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16053431819122037275241requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16053431819122037275241requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16053431819122037275241requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16053431819122037275241requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1611127117468239558394requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1611127117468239558394requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1611127117468239558394requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1611127117468239558394requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1611334641441-736123599requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1611334641441-736123599requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1611334641441-736123599requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1611334641441-736123599requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16113378282451044529009requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16113378282451044529009requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16113378282451044529009requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16113378282451044529009requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16119393700161679330568requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16119393700161679330568requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16119393700161679330568requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16119393700161679330568requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1611939781405-1622434999requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1611939781405-1622434999requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1611939781405-1622434999requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1611939781405-1622434999requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612529149476690762145requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612529149476690762145requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612529149476690762145requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612529149476690762145requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/16126628015651448867886requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/16126628015651448867886requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/16126628015651448867886requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/16126628015651448867886requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612711390139556174832requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612711390139556174832requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612711390139556174832requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612711390139556174832requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612712575639-1766288397requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612712575639-1766288397requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612712575639-1766288397requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612712575639-1766288397requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612713286160147529912requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612713286160147529912requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612713286160147529912requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612713286160147529912requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612714109267-2075710943requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612714109267-2075710943requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612714109267-2075710943requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612714109267-2075710943requestID.1/je.lck 新文件: pms/pms-web/bdbtmp/1612717830671191294880requestID.1/00000000.jdb 新文件: pms/pms-web/bdbtmp/1612717830671191294880requestID.1/je.info.0 新文件: pms/pms-web/bdbtmp/1612717830671191294880requestID.1/je.info.0.lck 新文件: pms/pms-web/bdbtmp/1612717830671191294880requestID.1/je.lck 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizMzPriceServiceMockTest.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizPriceServiceTest.java 新文件: pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git add . ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支与上游分支 'origin/feature/20210119_8832954_fixed_guid_1' 一致。 要提交的变更: (使用 "git restore --staged <文件>..." 以取消暂存) 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/BizMzEventChannelService.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/impl/BizMzEventChannelServiceImpl.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/price/serivce/impl/BizMzPriceServiceImpl.java 新文件: pms/pms-web/application.pid 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizMzPriceServiceMockTest.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizPriceServiceTest.java 新文件: pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git add . ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支与上游分支 'origin/feature/20210119_8832954_fixed_guid_1' 一致。 要提交的变更: (使用 "git restore --staged <文件>..." 以取消暂存) 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/BizMzEventChannelService.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/eventchannel/service/impl/BizMzEventChannelServiceImpl.java 修改: pms/pms-biz/src/main/java/cn/damai/mz/pms/biz/price/serivce/impl/BizMzPriceServiceImpl.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizMzPriceServiceMockTest.java 修改: pms/pms-web/src/test/java/cn/damai/mz/pms/test/service/price/BizPriceServiceTest.java 新文件: pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) ✗ git commit -m 'rollback' [feature/20210119_8832954_fixed_guid_1 3c6a37452] rollback 6 files changed, 100 insertions(+), 187 deletions(-) create mode 100644 pms/pms-web/src/test/java/cn/damai/mz/pms/test/utils/test.java ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支领先 'origin/feature/20210119_8832954_fixed_guid_1' 共 1 个提交。 (使用 "git push" 来发布您的本地提交) 无文件要提交,干净的工作区 ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) git status 位于分支 feature/20210119_8832954_fixed_guid_1 您的分支领先 'origin/feature/20210119_8832954_fixed_guid_1' 共 1 个提交。 (使用 "git push" 来发布您的本地提交) 无文件要提交,干净的工作区 ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1) git push 枚举对象: 67, 完成. 对象计数中: 100% (67/67), 完成. 使用 8 个线程进行压缩 压缩对象中: 100% (25/25), 完成. 写入对象中: 100% (36/36), 12.95 KiB | 4.32 MiB/s, 完成. 总共 36 (差异 13),复用 6 (差异 0) To http://gitlab.alibaba-inc.com/damai-mz/mz-pms.git 152f05efa..3c6a37452 feature/20210119_8832954_fixed_guid_1 -> feature/20210119_8832954_fixed_guid_1 ➜ mz-pms git:(feature/20210119_8832954_fixed_guid_1)