教程的版本控制设置 [英] Version control setup for a tutorial

查看:28
本文介绍了教程的版本控制设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试为与编程相关的教程设置版本控制.事实证明这是有问题的,因为有两种不同的历史:

I'm trying to set up version control for a programming-related tutorial. It's proving problematic because there are two different kinds of history:

教程中有正在构建的项目的历史,每章都有,读者将看到.如果我从不打算再次更改教程中已经编写的章节,我可以将每个章节作为标签存储在项目的历史记录中.

There's the history of the project being built by the tutorial, which is available for each chapter and is what the reader will see. If I never planned to change already-written chapters of the tutorial again, I could just store each chapter as a tag in the history of the project.

然后还有教程本身的历史(不仅是文本,还有我在项目的假装历史上的工作).如果我发现一个错误,我需要在第 1 章中返回并修复,在最后添加一个新的提交是行不通的,因为我想改变项目在那个阶段出现"的方式,即在项目历史中插入一个提交并将章节标签向前移动.

Then there's also the history of the tutorial itself (not only the text, but my working on the pretend history of the project). If I find a bug I need to go back and fix in chapter 1, adding a new commit to the end doesn't work because I want to change how the project "appeared" at that stage, i.e. insert a commit in the project history and move the chapter's tag forward.

到目前为止,我已经考虑了一些可能性 - 使用 git 分支,其中每章都是一个分支,每当我进行更改时都会重新定位到上一章的前面,我将补丁插入到一个可变补丁队列中,或者围绕一组我可以放入子存储库的模块构建教程.

So far I've thought about a few possibilities- using git branches where each chapter is a branch that gets rebased to the front of the previous chapter whenever I make a change, a mercurial patch queue that I insert patches into, or structuring the tutorial around a set of modules that I could put in subrepositories.

我想我会问是否有人对此类事情有经验,以及哪些解决方案有效,哪些无效.

I thought I'd ask if anyone has experience with this kind of thing and what solutions worked and didn't.

推荐答案

git rebase --interactive 可能是这里最直接的解决方案.这将让您选择要编辑的特定提交,然后在其上重新应用所有后续提交.当然,这应该不会比常规合并困难得多,这取决于您的更改范围.查看 git rebase 手册页中关于拆分提交的部分.这将允许您出于历史原因保留原始版本,然后在历史记录中紧随其后添加一个新提交,您可以在其中移动标签.

git rebase --interactive is probably the most straightforward solution here. That will let you choose a specific commit to edit, then reapply all the subsequent commits on top of it. Shouldn't be much more difficult than a regular merge, depending on how extensive your change is, of course. Check out the part of the git rebase man page on splitting commits. That will let you keep your original version for historical reasons, then add a new commit just after it in the history where you can move your tag.

这篇关于教程的版本控制设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆