完整版BedrockWiki镜像!
This commit is contained in:
@@ -1,89 +1,100 @@
|
||||
---
|
||||
title: Version Control
|
||||
title: 版本控制
|
||||
mentions:
|
||||
- SirLich
|
||||
- sermah
|
||||
---
|
||||
|
||||
Version control is the concept of backing up your code iteratively, so you can roll back to specific versions as needed. Version control could be achieved at the most basic level by taking a `.zip` of your addon every day and uploading it to google drive. This isn't unreasonable, but it has three significant difficulties that proper VCS (version control systems) fix:
|
||||
# 版本控制
|
||||
|
||||
- It isn't easy to compare versions
|
||||
- It isn't easy to _actually_ roll-back to a previous version
|
||||
- It doesn't do anything to help in team-collaboration
|
||||
<!--@include: @/wiki/bedrock-wiki-mirror.md-->
|
||||
|
||||
This tutorial will teach the basics of a tool called `git`, and a free, online git storage service called `GitHub. Anyone may follow along, but you will receive the most benefit if you are working in a team environment or often lose your work because you forget to back up.
|
||||
版本控制的核心概念是定期备份代码迭代版本,以便在需要时回滚到特定版本。最基本的版本控制可以通过每天将附加包打包成`.zip`并上传到谷歌网盘实现。这并非不合理,但存在三个显著缺陷,而专业的版本控制系统(VCS)能够有效解决:
|
||||
|
||||
This tutorial will not be focusing directly on teaching `git` or `GitHub`, as outside knowledge sources better do this. The focus will be on setting up these tools for Minecraft once the basics have been learned.
|
||||
- 版本差异比对困难
|
||||
- 实际回滚到旧版本操作繁琐
|
||||
- 对团队协作毫无帮助
|
||||
|
||||
本教程将介绍`git`工具的基本使用方法,以及免费的在线git托管服务`GitHub`。任何人都可以跟随学习,但如果您身处团队协作环境或经常因忘记备份而丢失工作成果,将会获得最大收益。
|
||||
|
||||
本教程不会直接教授`git`或`GitHub`的基础操作,因为这些知识已有优质外部资源可供学习。重点将放在掌握基础后如何针对Minecraft项目进行工具配置。
|
||||
|
||||
## Git
|
||||
|
||||
`git` is a tool installed locally on your machine and allows you to version your files. You can `commit` changes to your files with a small message (ex. "Fixed issue where dragons couldn't fly after being tamed"), view the full change-list, and quickly jump back to specific changes.
|
||||
`git`是安装在本地计算机上的版本管理工具,可对文件进行版本控制。您可以通过简短信息(例如"修复驯服后龙无法飞行的BUG")提交(`commit`)文件变更,查看完整修改记录,并快速回滚到特定版本。
|
||||
|
||||
Git is insanely powerful and the de-facto tool for all major programming projects. The most significant drawback for MC work is that it is _complicated_. Be patient while learning.
|
||||
Git功能强大且是主流编程项目的标配工具。其应用于Minecraft开发的主要缺点是学习曲线陡峭。请保持耐心循序渐进。
|
||||
|
||||
For a complete walkthrough of `git`, you should follow the following [git tutorial.](https://www.atlassian.com/git/tutorials/what-is-git)
|
||||
完整的`git`学习请参考[git官方教程](https://www.atlassian.com/git/tutorials/what-is-git)。
|
||||
|
||||
## GitHub
|
||||
|
||||
GitHub is a version of your git project (`repository`) that is hosted online. This allows multiple people to work on the same project at the same time and collaborate. This is very helpful for map-making. By hosting on Github, you can also (optionally) make your code public, making it easier than ever to share your addons with the world.
|
||||
GitHub是git项目(`repository`仓库)的在线托管平台,允许多人同时协作开发。这对于地图制作尤为实用。通过GitHub托管,您还可以选择将代码公开,更方便地向世界分享您的附加包。
|
||||
|
||||
For a complete walkthrough of using `Github`, you should follow this [github tutorial](https://guides.github.com/activities/hello-world/).
|
||||
完整的GitHub学习请参考[GitHub入门指南](https://guides.github.com/activities/hello-world/)。
|
||||
|
||||
## Vocabulary Quiz
|
||||
## 术语自测
|
||||
|
||||
If you've gotten this far, hopefully, you have a GitHub account and are familiar with `git` in a small way. The following terms will be used in this tutorial. If you don't know them, please google :)
|
||||
如果您已学习至此,希望您已注册GitHub账号并对`git`有初步了解。以下术语将在教程中使用,若不熟悉请自行查询:
|
||||
|
||||
- repository
|
||||
- branch
|
||||
- commit
|
||||
- github
|
||||
- git
|
||||
- repository(仓库)
|
||||
- branch(分支)
|
||||
- commit(提交)
|
||||
- github
|
||||
- git
|
||||
|
||||
# Setting up Git
|
||||
# Git环境配置
|
||||
|
||||
This assumes you are adding an _existing_ project to git. The steps are similar if you are starting from scratch.
|
||||
本节假设您要将已有项目加入git管理。新建项目的操作流程类似。
|
||||
|
||||
## Structure
|
||||
## 目录结构
|
||||
|
||||
The big issue with using `git` for addons is that `git` generally works by encapsulating a _single_ folder and managing it. Of course, in Bedrock Addons, assets are spread across two folders: The `BP`, and `RP`. To get around this issue, we will place our repository outside of the `com.mojang` folder entirely and then use window `junctions` to "copy" the folders in.
|
||||
在附加包开发中使用`git`的主要问题在于:git通常通过管理单个文件夹实现版本控制,而基岩版附加包资源分散在`BP`和`RP`两个文件夹。为解决此问题,我们将仓库完全置于`com.mojang`文件夹之外,使用Windows符号链接(`junctions`)实现文件夹映射。
|
||||
|
||||
There are many advantages of placing our project in a separate location:
|
||||
将项目置于独立位置有以下优势:
|
||||
|
||||
- We can include additional files as needed, such as config files, tools, notes, .bb files, etc
|
||||
- We can combine the RP and the BP into one repository
|
||||
- All of our projects can be easily viewed in a simple location, instead of nested deep within com.mojang
|
||||
- 可自由添加配置文件、工具、笔记、.bb文件等附加内容
|
||||
- 可将RP和BP整合至同一仓库
|
||||
- 所有项目可在统一位置查看,避免深埋于com.mojang目录中
|
||||
|
||||
## Creating a Git Repository
|
||||
## 创建Git仓库
|
||||
|
||||
Pick a convenient location for your projects. I placed mine at `C:/sirlich/projects`. Make a new folder with the name of your map. We will be using `wiki` as the name of our mock project.
|
||||
为项目选择合适的位置。示例使用`C:/sirlich/projects`。新建以项目命名的文件夹,示例项目名为`wiki`。
|
||||
|
||||
Right-click the folder, and click `"Open git Bash"`. If this option doesn't appear, you can open `git bash` from the start menu and navigate your project folder. If you don't have `git bash` installed, you should do so now.
|
||||
右键点击文件夹选择`"Open git Bash"`。若未显示此选项,可通过开始菜单打开`git bash`并导航至项目目录。若未安装`git bash`请立即安装。
|
||||
|
||||
Type: `git init`. This will create a blank repository in your project.
|
||||
输入命令:`git init`。这将在项目中创建空白仓库。
|
||||
|
||||
## Linking your existing RP and BP
|
||||
## 链接现有RP和BP
|
||||
|
||||
The next step is to make the repository aware of your RP and BP folders. We will be using window symlink "junctions". When we create a junction, we essentially create a wormhole in our file system that will make it appear like your files are in two places at once. Deleting/editing/adding files is perfectly copied over.
|
||||
接下来通过创建Windows符号链接让仓库识别您的RP和BP文件夹。符号链接相当于文件系统的虫洞,使文件看似同时存在于两个位置。删除/编辑/添加操作会实时同步。
|
||||
|
||||
Type: `mklink /J wiki_RP "C:/path/to/RP/in/com/mojang"`
|
||||
Type: `mklink /J wiki_BP "C:/path/to/BP/in/com/mojang"`
|
||||
输入命令:
|
||||
`mklink /J wiki_RP "C:/path/to/RP/in/com/mojang"`
|
||||
`mklink /J wiki_BP "C:/path/to/BP/in/com/mojang"`
|
||||
|
||||
When you are finished, you should see `wiki_RP` and `wiki_BP` in your project folder, containing all your assets, existing files, etc.
|
||||
完成后,项目文件夹中将出现`wiki_RP`和`wiki_BP`目录,包含所有现有资源文件。
|
||||
|
||||
You can now push this repository to `github`, following the tutorial above.
|
||||
此时可按照前述教程将仓库推送至`github`。
|
||||
|
||||
## Extra Files
|
||||
## 附加文件
|
||||
|
||||
Because we created our repository based on symlinks, we can add anything we like into the project folder without worrying about breaking the com.mojang folder. I like to track `.bb` files, cover-art files (`.kra` etc.).
|
||||
由于我们通过符号链接创建仓库,可在项目文件夹中添加任意文件而不影响com.mojang目录。推荐追踪`.bb`文件、封面设计文件(如`.kra`格式)等。
|
||||
|
||||
You can also add notes, video files, or anything else you want to track.
|
||||
您还可以添加笔记、视频文件等需要版本控制的任何内容。
|
||||
|
||||
## Working with your VCS
|
||||
## VCS使用规范
|
||||
|
||||
The main things to remember about working with VCS:
|
||||
使用版本控制系统需牢记以下要点:
|
||||
|
||||
- Always `pull` before starting work
|
||||
- Commit and `push` often
|
||||
- Always `push` before stopping work
|
||||
- If you screw up your files super bad, you can always reset to the last working version. If you commit/push often, hopefully, this wasn't too long ago.
|
||||
- Always, and I mean `always` make good commit messages. It's vital when you have to roll back.
|
||||
- 开始工作前务必先`pull`拉取最新版本
|
||||
- 频繁`commit`提交并`push`推送
|
||||
- 结束工作前必须`push`推送更改
|
||||
- 若文件严重损坏,可随时重置到最近可用版本。经常提交/推送能最大限度减少损失
|
||||
- 必须(强调)编写规范的提交信息,这在需要回滚时至关重要
|
||||
|
||||
::: code-group
|
||||
```json [示例符号链接]
|
||||
mklink /J demo_RP "C:/Users/Steve/AppData/Local/Packages/Microsoft.MinecraftUWP_8wekyb3d8bbwe/LocalState/games/com.mojang/development_resource_packs/demoRP"
|
||||
```
|
||||
:::
|
||||
Reference in New Issue
Block a user