idea local history说明


idea local history说明

               

官网:https://www.jetbrains.com/help/idea/2021.3/local-history.html

        

              

**************

local history说明

            

Local History helps you constantly track all changes made to a project 
independently of version control.
#local history独立于版本控制,可追踪项目的所有变更

Unlike version control systems, which only keep track of the differences made 
between commits, Local History offers much more. It automatically records your 
project's state as you edit code, run tests, deploy applications, and so on, and 
maintains revisions for all meaningful changes made both from the IDE and externally.
#版本控制系统只会追踪提交操作的变化,local hostory具有更多功能
#local history会编辑代码、测试、发布应用等操作的同时记录项目状态
#local hostory保存了所有有意义的项目版本变更(IDE和外部操作引起的版本变更)

Acting as your personal version control system, Local History lets you restore 
deleted files, bring back separate changes, or roll back to any state of a file 
even if no version control is enabled for your project yet, or if an unwanted 
change was made after your last commit. It may also serve as a recovery source if 
your computer restarts unexpectedly before you can take any action.
#local history充当个人版本管理系统,可存储删除的文件、恢复单独的变化、或者回滚指定的文件
#也可以在电脑意外重启,没有进行任何操作(如保存文件)时,进行文件文件

Note that Local History is not a replacement for a proper version control for long-
term versioning. Local History is cleared when you install a new version of 
IntelliJ IDEA. It also has a retention period and maximum size, so revisions are 
not guaranteed to persist.
#注意,local history不是版本管理系统(如git)的替代方案
#当安装新的idea版本后,local history会清空
#同时,local history也会有最长保存时间,默认是5天

               

local history存储位置

windows:%LOCALAPPDATA%\JetBrains\<product><version>
如:C:\Users\JohnS\AppData\Local\JetBrains\IntelliJIdea2021.3

mac:~/Library/Caches/JetBrains/<product><version>
如:~/Library/Caches/JetBrains/IntelliJIdea2021.3

linux:~/.cache/JetBrains/<product><version>
如:~/.cache/JetBrains/IntelliJIdea2021.3

               

           

**************

文件恢复

           

Let's imagine you made a series of changes to a file since your last commit before 
your realized you've deleted a meaningful chunk of code. The Undo action can't help 
you here because that change is too far away and you'll be forced to discard other 
changes if you use it
#最后一次操作之前对文件做了一系列的修改,这是发现删除了有意义的代码块
#不能使用undo操作直接恢复代码,因为这会导致其他代码被丢弃
#此时就可使用local history恢复代码

          

***************

查看文件操作记录

               

方法一:文件页面上双击shift ==> 搜索框输入local history ==> show hidtory

           

           

           

说明:文件页面上双击shift显示的是当前文件的操作记录、空页面上双击shift会显示整个项目的操作记录

              

方法二:文件或者目录右击  ==> local history ==> show history

           

           

                

***************

文件整体恢复

       

恢复某一版本的全部文件:版本记录右击 ==> revert

           

该版本下的文件HelloController、Hello2Controller全部恢复到之前的状态

              

恢复某一版本的单个文件:选中需要恢复的文件右击 ==> revert selection

           

说明:恢复单个文件也可直接查看对应文件的操作记录,直接revert到对应版本

           

***************

文件部分恢复

      

恢复文件的代码片段:查看包含片段的版本记录,点击 》即可

           

            

***************

恢复删除的文件

      

查看包含被删文件的目录版本记录 ==> 找到被删文件,右击revert selection

           

             

                  

**************

版本记录打标签

           

文件或者目录右击 ==> local history ==> put label

           

           

说明:如果连续两次打标签,中间未做任何修改,则后一次标签会覆盖前一次标签内容

              

                      

**************

共享操作记录

           

操作记录右击 ==> create patch

           

           

           

           

local_history3.patch文件

Index: src/main/java/com/example/demo/controller/HelloController.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/src/main/java/com/example/demo/controller/HelloController.java b/src/main/java/com/example/demo/controller/HelloController.java
--- a/src/main/java/com/example/demo/controller/HelloController.java	(date 1642315916864)
+++ b/src/main/java/com/example/demo/controller/HelloController.java	(date 1642315916864)
@@ -13,6 +13,11 @@
 
     @RequestMapping("/hello3")
     public String hello3(){
-        return "success";
+        return "success 3";
+    }
+
+    @RequestMapping("/hello5")
+    public String hello5(){
+        return "success 5";
     }
 }

           

               

**************

操作记录保存时间

           

默认保存5天,修改保存时间:双击shift ==> 搜索框输入registry

           

           

 说明:如果修改为0,则表示关闭local history功能

             

也可以使用虚拟机参数修改历史操作保存时间:

-DlocalHistory.daysToKeep=30

             

                                                              

  • 3
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值