简体   繁体   English

SVN转换为Git。 新分支新来源

[英]SVN to Git. New branch with new source

We're moving from SVN to Git. 我们正在从SVN迁移到Git。

I setup empty Git repo on our server. 我在我们的服务器上设置了空的Git存储库。 Set up a working directory on my local machine and downloaded the complete source from SVN repo to this local folder (Working directory). 在本地计算机上设置一个工作目录,并将完整的源代码从SVN存储库下载到此本地文件夹(工作目录)。 I pushed all these files to master branch and created two branches, dev and staging . 我将所有这些文件推送到master分支,并创建了两个分支devstaging This is all fine. 一切都很好。

Now I want to create a new branch called v1.0 with completely different source (lot of new features). 现在,我想用完全不同的源(很多新功能)创建一个名为v1.0的新分支。 My plan is to create a new working directory (local folder) called v1.0 and import the source (from another SVN repo) to this folder. 我的计划是创建一个名为v1.0的新工作目录(本地文件夹),并将源(从另一个SVN存储库)导入此文件夹。 I want to point this folder to the v1.0 branch. 我想将此文件夹指向v1.0分支。

Can someone explain steps how this can be done? 有人可以解释步骤如何完成吗? (I am fairly new to Git) (我对Git相当陌生)

Thanks in advance. 提前致谢。

If the project is completely different it has more sense to create a separate git repo. 如果项目完全不同,则创建单独的git repo更具意义。 The main philosophy change while moving from svn to git is to prefer to have multiple repositories for each logical module (eg library, program, etc). 从svn转到git时,主要的哲学变化是,每个逻辑模块(例如库,程序等)都希望具有多个存储库。

However, if you really want to have a single repo with git, you could create an orphan branch: git checkout --orphan v1.0 . 但是,如果您真的想使用git进行单个git checkout --orphan v1.0 ,则可以创建一个孤立分支: git checkout --orphan v1.0

if i understand correctly, that you are currently not at all concerned with keeping the svn-history in your git repository, why not do something as simple as: 如果我理解正确,那么您当前根本不关心将svn历史记录保留在git存储库中,为什么不做以下简单的事情:

$ cd project
$ git checkout -b v1.0
$ rm all files not needed
$ # the above could also just be "rm *", just be careful to not delete .git
$ cp -r /path/to/project-1.0/* .
$ git add .
$ commit -a -m "imported v1.0"

git should figure out by itself which files have not been touched, or renamed, or ... git应该自己找出哪些文件没有被触摸,重命名或...

and having all in one repository, makes it easy to cherrypick (where this is possible) 并且将所有内容存储在一个存储库中,可以很容易地进行选择(在可能的情况下)

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

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