-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
160 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
--- | ||
title: 代码备份 | ||
date: 2022-05-02 | ||
authors: kuizuo | ||
tags: [随笔] | ||
--- | ||
|
||
前段时间因为笔记本不在身边,导致一些本地磁盘代码数据没法直接同步过来。于是就准备把这些年写的代码重新整理一下,谈谈常用备份手段以及我的[最佳手段](#最佳实现) | ||
|
||
<!-- truncate --> | ||
|
||
## 备份手段 | ||
|
||
### 本地硬盘 | ||
|
||
大多数代码的存储方式,方便存取,我通常会新建一个驱动器 **代码 (F:)** 来将所有代码放在此处,可能还会自备一个移动硬盘来存储代码。 | ||
|
||
#### 优点 | ||
|
||
无需网络,保存时间久,**读写数据快**。 | ||
|
||
#### 缺点 | ||
|
||
数据同步不方便,难以做到跨端跨设备共享。万一硬盘出了点问题,代码将难以恢复。 | ||
|
||
### 网盘 | ||
|
||
例如某度网盘,Onedrive等等,这类备份通常有一定的限制,例如下载限速严重,空间限制,保存期限等等,具体以实际使用网盘为例。 | ||
|
||
在某度网盘中,选择你的想备份的文件夹,是可以做到文件夹自动备份,但对于你项目中的依赖文件(例如Node的node_module)那不小的空间也将备份,但有文件夹数量以及大小限制,如下图,这里只是简单一提,不作为备用手段。 | ||
|
||
 | ||
|
||
#### 优点 | ||
|
||
相比本地硬盘而已,**网盘更易分享**,在其他设备中只需要登录网盘账号或访问网盘所分享的链接。 | ||
|
||
#### 缺点 | ||
|
||
有些免费的网盘,必然有一定的限制,例如空间限制,下载限制,远不如本地硬盘。如果不付费的话,体验效果堪忧。 | ||
|
||
### 代码托管平台 | ||
|
||
代码托管平台有很多,例如Github、Gitee等等,甚至可以自建一个像GItLab的代码托管平台。 | ||
|
||
#### 优点 | ||
|
||
**代码实时性强**,并且基于Git版本管理工具可以很方便查看代码的历史操作,对于项目类的而言非常方便。 | ||
|
||
#### 缺点 | ||
|
||
对于一些公有项目而言,一些私密信息(密码)不易于上传,在其他设备拉取代码就不存在这部分数据。同时**对于大量代码就束手无策**。 | ||
|
||
## 最佳实现 | ||
|
||
介绍完上面的几种代码备份手段,各自都有优缺点,至于如何选择就因人而异,这里就说说我是如何备份代码的。 | ||
|
||
### 全部代码 | ||
|
||
对于全部代码而言,肯定是多备份远优于不备份的。所以我通常会在本地电脑硬盘中备份两份代码,一份就正常放在固态硬盘上,另一份则放在机械硬盘,同时再备份一份代码在网盘上。 | ||
|
||
但机械硬盘与网盘的备份时间一致,都是定期或阶段性的备份(甚至可能会忘记备份),所以这种对代码的实时性要求不高,通常这类代码为学习代码以及工具类相关代码。 | ||
|
||
### 项目代码 | ||
|
||
对于项目代码而言,我是毫不犹豫的选择代码托管平台,主要使用到版本管理工具Git,可以很好的查看代码的全部历史记录以及修改追踪能力。易于维护的同时,代码分享与同步也比网盘来的高效。设置好.gitignore也不会将非必要的文件(依赖文件,打包后的文件,生产环境下的配置文件)上传上去。 | ||
|
||
## 最后 | ||
|
||
**永远不要闲备份麻烦,当你辛辛苦苦写的代码丢失时,那才是真正的麻烦。** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters