diff --git a/development-tools/rtthread-studio/um/figures/git0.png b/development-tools/rtthread-studio/um/figures/git0.png new file mode 100644 index 0000000000000000000000000000000000000000..f05f8f201882178556455897783306c2ddf197a7 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git0.png differ diff --git a/development-tools/rtthread-studio/um/figures/git1.png b/development-tools/rtthread-studio/um/figures/git1.png new file mode 100644 index 0000000000000000000000000000000000000000..b6e8ba899150c9348cd9601f32bf02c1aa9b8d53 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git1.png differ diff --git a/development-tools/rtthread-studio/um/figures/git10.png b/development-tools/rtthread-studio/um/figures/git10.png new file mode 100644 index 0000000000000000000000000000000000000000..5e3da18b7a36499e57f75b1f4d4d8c1b636017c7 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git10.png differ diff --git a/development-tools/rtthread-studio/um/figures/git11.png b/development-tools/rtthread-studio/um/figures/git11.png new file mode 100644 index 0000000000000000000000000000000000000000..15ec1bb8b65818c196b036a15cc677fcf896fbf2 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git11.png differ diff --git a/development-tools/rtthread-studio/um/figures/git12.png b/development-tools/rtthread-studio/um/figures/git12.png new file mode 100644 index 0000000000000000000000000000000000000000..f8a7d3c00b9f5f74ffb6e31b71786d680a759f4d Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git12.png differ diff --git a/development-tools/rtthread-studio/um/figures/git13.png b/development-tools/rtthread-studio/um/figures/git13.png new file mode 100644 index 0000000000000000000000000000000000000000..23617e2a865165e53fcb1603775454fb4f6b00ba Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git13.png differ diff --git a/development-tools/rtthread-studio/um/figures/git14.png b/development-tools/rtthread-studio/um/figures/git14.png new file mode 100644 index 0000000000000000000000000000000000000000..0e8f62a2b3f655afe207014c9bca3257683c4721 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git14.png differ diff --git a/development-tools/rtthread-studio/um/figures/git15.png b/development-tools/rtthread-studio/um/figures/git15.png new file mode 100644 index 0000000000000000000000000000000000000000..3040ddc1fcfb737eb651ac61eefa5dbb1b7c4575 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git15.png differ diff --git a/development-tools/rtthread-studio/um/figures/git16.png b/development-tools/rtthread-studio/um/figures/git16.png new file mode 100644 index 0000000000000000000000000000000000000000..b7c3669ec12c95df248a623dd55785958366107d Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git16.png differ diff --git a/development-tools/rtthread-studio/um/figures/git17.png b/development-tools/rtthread-studio/um/figures/git17.png new file mode 100644 index 0000000000000000000000000000000000000000..a8a7aaf76becfa2df9a8c40ca9824360be963667 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git17.png differ diff --git a/development-tools/rtthread-studio/um/figures/git18.png b/development-tools/rtthread-studio/um/figures/git18.png new file mode 100644 index 0000000000000000000000000000000000000000..d3ae5e9250c2a6ea12087c59014d034cd9e1968b Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git18.png differ diff --git a/development-tools/rtthread-studio/um/figures/git19.png b/development-tools/rtthread-studio/um/figures/git19.png new file mode 100644 index 0000000000000000000000000000000000000000..6fa4fe89b81ec5ab5a77d5a0d028f519078a5241 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git19.png differ diff --git a/development-tools/rtthread-studio/um/figures/git2.png b/development-tools/rtthread-studio/um/figures/git2.png new file mode 100644 index 0000000000000000000000000000000000000000..7f5ca616cf25fcee36c5b5b65b0c613bbd735e4e Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git2.png differ diff --git a/development-tools/rtthread-studio/um/figures/git20.png b/development-tools/rtthread-studio/um/figures/git20.png new file mode 100644 index 0000000000000000000000000000000000000000..ab738064e01ef03681f3b28be41338ba5c676dd9 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git20.png differ diff --git a/development-tools/rtthread-studio/um/figures/git21.png b/development-tools/rtthread-studio/um/figures/git21.png new file mode 100644 index 0000000000000000000000000000000000000000..bcf366f6df166245f0f6e6fc742ae815551d2772 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git21.png differ diff --git a/development-tools/rtthread-studio/um/figures/git3.png b/development-tools/rtthread-studio/um/figures/git3.png new file mode 100644 index 0000000000000000000000000000000000000000..857d419e2f07896c2bdd0e476e9cda0f1f6ba1e5 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git3.png differ diff --git a/development-tools/rtthread-studio/um/figures/git4.png b/development-tools/rtthread-studio/um/figures/git4.png new file mode 100644 index 0000000000000000000000000000000000000000..9596bfd49efe6f0ea21a7afd4b4b6518d9fffc54 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git4.png differ diff --git a/development-tools/rtthread-studio/um/figures/git5.png b/development-tools/rtthread-studio/um/figures/git5.png new file mode 100644 index 0000000000000000000000000000000000000000..96ea15b962704deaedd237e1a2a28001dbe4abb0 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git5.png differ diff --git a/development-tools/rtthread-studio/um/figures/git6.png b/development-tools/rtthread-studio/um/figures/git6.png new file mode 100644 index 0000000000000000000000000000000000000000..b3ba59431144feba293d133e3920c3a4def3421e Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git6.png differ diff --git a/development-tools/rtthread-studio/um/figures/git7.png b/development-tools/rtthread-studio/um/figures/git7.png new file mode 100644 index 0000000000000000000000000000000000000000..0710e9b9315901bc56edf8ec2e688d41d55d0b9c Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git7.png differ diff --git a/development-tools/rtthread-studio/um/figures/git8.png b/development-tools/rtthread-studio/um/figures/git8.png new file mode 100644 index 0000000000000000000000000000000000000000..5090bbe75e0b998395ab3a105bb898149acc4af2 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git8.png differ diff --git a/development-tools/rtthread-studio/um/figures/git9.png b/development-tools/rtthread-studio/um/figures/git9.png new file mode 100644 index 0000000000000000000000000000000000000000..a9f74e98b0b11d8efacd96b0cd6528f04a918d10 Binary files /dev/null and b/development-tools/rtthread-studio/um/figures/git9.png differ diff --git a/development-tools/rtthread-studio/um/studio-user-manual.md b/development-tools/rtthread-studio/um/studio-user-manual.md index 7c6b6b460cf72f6f236e5929b897ac178220ffc2..f7e4272c2de40e7b316411335ac9a745f70bc54d 100644 --- a/development-tools/rtthread-studio/um/studio-user-manual.md +++ b/development-tools/rtthread-studio/um/studio-user-manual.md @@ -1022,6 +1022,144 @@ RT-Thread Studio 自带 MarkDown 编辑器,若工程里有 md 文件,只需 ![editmd](figures/editmd.png) +## 版本控制 + +### Git 简介 + +Git 是目前最先进的分布式版本控制系统。什么是版本控制系统? + 形象地讲,版本控制就是按照纵向或横向的维度记录当前工程下的变更并进行管理,方便用户可以穿梭于当前工程的不同的变更状态,纵向的维度就是时间的维度,而横向的维度就是分支的维度。在软件开发中经常利用分支的功能将稳定和变动隔离开来,已经稳定的代码是默认的主分支,而新的特性,功能等则是其他分支。 + 如何使用 Git 的分支特性并无标准答案,但却有大家总结或约定俗称的使用方式,这里推荐简要了解一下[git分支管理策略](https://www.ruanyifeng.com/blog/2012/07/git.html)。 + 那么什么是分布式版本控制系统?版本控制系统并非只有 Git 一种,再此之前还有 SVN 和 CSV,相对的,这两者是集中式版本控制系统。分布式版本控制系统会在每台部署了版本控制的电脑上存储完整的版本库,而集中式版本控制系统则只会在一台主机上保存版本库。因此分布式版本库不仅不需要联网就可以使用,而且更安全,更方便。 + +#### Git 基本概念 + +想要用好 Git,首先要了解 Git 的几个基本概念 + +​ [![pic2](figures/git0.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/9990f454f96cd9362649e0298be13b29/pic2.png) + +**Workspace**: 工作区,平时存放工程代码的地方,也就是工程文件夹。 + +**Index / Stage**: 暂存区,用于临时存放你的改动,实际上这是一个文件,里面保存即将提交的文件的信息,一般存放在隐藏目录.git 目录下的 index 文件中。 + +**Repository**: 仓库区(或版本库),本地仓库,当前工程路径下的隐藏目录 .git。 + +**Remote**: 远端仓库。 + +#### Git 工作流程 + +以上图为例: + +1. 从远端仓库 clone 一个仓库到本地,或在本地创建并初始化一个仓库 +2. 在工作区中对文件进行添加、编辑、修改、删除 +3. 将需要进行版本管理的文件从工作区中 add 后放入暂存区 +4. 确认需要保存的更改从暂存区中 commit 至版本库 +5. 最后如果需要将本地版本库同步就将版本库 push 至远端工作区 + +### RT-Thread studio 中 git 信息的配置 + +按如下图配置 RT-Thread studio 中的 git 插件 + +- 打开窗口 -> 首选项 -> 配置 + [![image](figures/git1.png) ](https://git.rt-thread.com/realthread/ide_bug_report/uploads/8219aef9907da695186a050cb2b7ffd0/image.png) +- 在图中 user下填入代码托管平台的 email 和 name,如需配置网络代理,可配置 http 代理信息 + [![image](figures/git2.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/6d74921b52b8604a0c5b43a46fad176d/image.png) + +### RT-Thread studio 中 Git 视图面板介绍 + +按下图打开 git 视图 + +[![image](figures/git3.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/ba43b92b7d2c1b927eb00d6a0ab04436/image.png) + +[![image](figures/git4.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/e5f1a55db6a02e87e23e9370a5bac1e5/image.png) + +[![image](figures/git5.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/5819713709ccc78d5ea2c2d1ae0ddbc6/image.png) + +上图所示, 从左至右的按钮的功能分别为 + +- 导入外部已存在的本地版本库 +- 从远端仓库 clone 一个版本库至本地 +- 创建一个新的版本库并添加至当前视图 +- 刷新 +- 与工作树所选内容连接 +- 显示平行分支布局 +- 显示最新分支的提交 + +[![image](figures/git6.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/84e8980b0171ca74365b55d41bf9af63/image.png) + +- 左边区域为版本库的文件树 +- 右边区域为git相关操作的面板,通过打开不同的选项卡可以进行如diff,commit等基本操作 + +### Studio创建本地仓库 + +切换至 git 视图后按如下步骤新建本地仓库 + +[![image](figures/git7.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/d912f78e3e658563b2fa9c34723f0bb6/image.png) + +[![image](figures/git8.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/5f5eb9eabafe6980afdfbea77295f22c/image.png) + +也可以直接从菜单栏新建本地仓库 + +[![image](figures/git9.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/729a69d842ee3e47824c40c6f716e9d0/image.png) + +注:新建本地仓库后需要新建工程并保存至仓库路径,然后添加至暂存区才可以跟踪工程文件的变更 + +### RT-Thread studio 导入外部仓库 + +切换至 git 视图后按如下步骤添加外部已存在仓库至 RT-Thread studio + +[![image](figures/git10.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/9f3b130d1b5367cf162c898f2eb46b0b/image.png) + +### RT-Thread studio 克隆远程仓库 + +按如下图所示步骤克隆远程仓库至 RT-Thread studio + +[![image](figures/git12.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/2a6fae6d7d715fbb7e08860eeb051336/image.png) + +[![image](figures/git11.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/f09ad6faa056bac2f2c11d8f8c67a51a/image.png) + +克隆后导入工程(注:只有 eclipse 工程才可以导入成功) + +[![image](figures/git13.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/aeebf923eaa3cd5639cdbec007526114/image.png) + +[![image](figures/git14.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/63d2adf3536339ed735eb460b573d310/image.png) + +**注:从远程仓库克隆至本地后需要导入 RT-Thread studio 工程,才可以在项目资源管理器中显示工程内容** + +### Git 在 RT-Thread studio 中的基本操作 + +#### 拉取远程仓库代码 + +[![image](figures/git15.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/ea5cf7e3fb50b65e2432e3ac516b6fd7/image.png) + +#### 添加文件到暂存区 + +[![image](figures/git16.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/0de114a30a6a9ecbb21a06aa016f8175/image.png) + +#### 暂存区内容添加到仓库 + +[![image](figures/git17.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/6d8be0fb7c0ff834b6cc7fcbd1b98df1/image.png) + +[![image](figures/git18.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/d2849b53ea9b96d4eaa03fe166c5e4d1/image.png) + +#### 推送本地仓库至远程仓库 + +[![image](figures/git19.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/dc694bc9ee09cf4bc0730da9af1937f3/image.png) + +#### 文件历史版本比较 + +按如图所示打开文件变更比较 + +[![image](figures/git20.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/07b8f2b4e10673fa900b045bcffbc09b/image.png) + +[![image](figures/git21.png)](https://git.rt-thread.com/realthread/ide_bug_report/uploads/85da1a2c943316c91c152fbe6529da1f/image.png) + +### RT-Thread studio 工程与.gitignore + +.gitignore用来描述不被git添加到版本管理中的文件,RT-Thread studio的工程中大概有如下几类文件可以不被包括到版本管理中 + +1. 工程编译过程中产生的文件,如.elf、.bin、.hex、.map、.o,Debug 目录下以及 build 目录下的文件等 +2. 与当前工程不相关的工程配置文件,如.vscode目录下的文件,.uvguix*等 + ## 快捷键 ### 如何查看和修改快捷键