将旧版本的代码添加到git repo [英] Adding older versions of code to git repo

查看:141
本文介绍了将旧版本的代码添加到git repo的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的项目有一个git repo,我的第一次提交是在v1.2。在git之前,我使用我的代码的每日快照来保证它的安全。现在我想将所有我已经加入到回购库中的快照添加到v0.3中,但我已经在1.2之上提供了相当多的提交。那么最好的方法是什么?我应该只是一个接一个地提交快照并添加标签吗?或者我应该为所有这些快照创建另一个分支?或者,也许开始一个新的回购与v0.3和提交所有快照,然后以某种方式合并回购与旧的基于1.2的?回到顶端> Ben的回答绝对是一种好方法如果你还没有做这个仓库公开的话。



另一方面,如果你已经发布你的当前仓库,因此不想移植它根据以前的工作,我会建议一些不相交的东西。我个人很想试试在存储库中创建另一个名为legacy的分支,或者其他一些分支,使用第一个快照在新的根提交时启动它,并将所有其他分支提交给它。大概这里的主要用途就是归档这些工作,并且可能在某个时候检查出它或者与之对照 - 即使历史记录有点奇怪,你也可以完成所有工作:

 #没有共同的提交! 
$ b - o - o - o - o - o(主)

- o - o - o(遗产)


I have a git repo for my project, and my first commit was at v1.2. Before git I used daily snapshots of my code to keep it safe. I would now like to add all of the snapshots I have into the repo as well starting v0.3, but I already have quite a number of commit on top of 1.2. So what's the best way to proceed? Should I just commit the snapshots one by one and add tags? Or should I create another branch perhaps for all these snapshots? Or maybe start a new repo with v0.3 and commit all snapshots then somehow merge the repo with the old 1.2 based one?

解决方案

Ben's answer is definitely a good way to go if you haven't made this repostory public.

If on the other hand you've already published your current repository, and therefore don't want to transplant its root commit onto the previous work, I'd suggest something disjoint. I'd personally be tempted to just create another branch in the repository called "legacy" or some such, start it at a new root commit with your very first snapshot, and commit all the others on top of it. Presumably the primary use here is just archiving that work, and possibly checking it out or diffing against it at some point - and you'll be able to do all of that even if the history is a little weird:

# No commits in common!

- o - o - o - o - o (master)

- o - o - o (legacy)

这篇关于将旧版本的代码添加到git repo的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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