简体   繁体   English

仅将历史记录从CVS存储库导入到已创建的git存储库中

[英]Import only history from CVS repository into already created git repository

At work we have a CVS repository that has commits stretching back nearly 15 years. 在工作中,我们有一个CVS信息库,其提交可以追溯到近15年。 A couple of years ago that repository was converted to git and uploaded to a public GitHub repository. 几年前,该存储库已转换为git并上传到公共GitHub存储库。 However, the git repository was just initialized with the current version of the files, no history was imported (not my doing). 但是,git存储库只是使用文件的当前版本进行了初始化,没有导入任何历史记录(不是我的工作)。 The CVS history is straightforward and linear--we never used CVS branches. CVS的历史是直接且线性的-我们从未使用过CVS分支。 It is not a highly-active repository: there have been only about 25 commits to the public git repository since it was created. 它不是一个非常活跃的存储库:自创建以来,仅对公共git存储库进行了25次提交。

I would like to be able to import the CVS history into the existing git repository without necessarily creating a new repository. 我希望能够将CVS历史记录导入到现有的git存储库中,而不必创建新的存储库。 From what I've read in the documentation for git-cvsimport or cvs2git , those tools always create new repositories. 从我在git-cvsimportcvs2git文档中阅读的内容cvs2git ,这些工具始终会创建新的存储库。 Alternatively, I could do a fresh cvs/git conversion and upload the new repository in place of the current one, and apply the 25 post-cvs commits. 另外,我可以进行新的cvs / git转换,并上传新的存储库来代替当前存储库,并应用25个post-cvs提交。 Is this possible, and if so, what is the recommended way to do this? 这可能吗?如果可以,推荐的方法是什么? I have read & write access to both the CVS and git repositories, and server access to the CVS one if necessary. 我具有对CVS和git存储库的读写访问权限,并且在必要时可以对CVS进行服务器访问。

I am fairly comfortable with simple git branching, merging, and rebasing, but I would not say I am an expert (I consult the Pro Git book a lot). 我对简单的git分支,合并和重新定级感到非常满意,但是我不会说我是专家(我经常参考Pro Git书)。

I think the solution is to create temporary branch ("start") from the first commit in the master branch, then generating and importing history from CSV into another temporary branch ("import"), merging with strategy ours from the "start" branch and merging from "master" branch the newer commits and renaming the "import" branch to "master": 我认为解决方案是从master分支中的第一次提交创建临时分支(“开始”),然后从CSV生成历史记录并将其导入到另一个临时分支(“ import”)中,并从“ start”分支与我们的策略合并并从“ master”分支合并较新的提交,并将“ import”分支重命名为“ master”:

# create new git repository by running cvs2git in import-git-path
# change directory to your current repository
git log
# find the first commit
git checkout -b start "first-commit"
git checkout --orphan branch
rm -rf * .gitignore # or any other file
git add -A
git remote add import-repo import-git-path
git pull import-repo master
git merge -s ours start
git merge master
git branch -D start
git branch -D master
git branch -m import master

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM