我有一个在svn存储库中有超过3年历史的项目。它被迁移到git,但是做这个的人,只是拿最后一个版本,抛弃所有这3年的历史。更改根提交父指向另一个提交(连接两个独立的git存储库)
现在项目在一个存储库中有最近3-4个月的历史记录,并且我已经将其他3年的svn历史记录导入到新的git存储库中。
是否有某种方法将第二个存储库的根提交连接到第一个提交的最后一个提交?
它是这样的:
* 2017-04-21 - last commit on master
|
* 2017-03-20 - merge branch Y into master
|\
| * 2017-03-19 - commit on branch Y
| |
* | 2017-03-18 - merge branch X into master
/| * 2017-02-17 - commit on another new branch Y
* |/ 2017-02-16 - commit on branch X
| * 2017-02-15 - commit on master branch
* | 2017-01-14 - commit on new branch X
\|
* 2017-01-13 - first commit on new repository
|
* 2017-01-12 - init new git project with the last version of the code in svn repository
.
.
There is no relationship between the two different repositories yet, this is what I wanna
do. I want to connect the root commit of 2nd repository with the last commit of the first
one.
.
.
* 2017-01-09 - commit
|
* 2017-01-08 - commit
|
* 2017-01-07 - merge
/|
* | 2016-01-06 - 2nd commit the other branch
| * 2016-01-05 - commit on trunk
* | 2016-01-04 - commit on new branch
\|
* 2015-01-03 - first commit
|
* 2015-01-02 - beggining of the project
更新:
我刚刚得知,我需要做一个答案是使用git rebase
,但如何?请让我们考虑提交日期,例如它是SHA-1代码...git filter-branch
和--parent-filter
选项,而不是git rebase
。
更新2:
我试着命令git filter-branch --parent-filter 'test $GIT_COMMIT = 443aec8880e898710796a1c4fb4decea1ca5ff66 && echo "-p 98e2b95e07b84ad1e40c3231e66840ea910e9d66" || cat' HEAD
并没有奏效:
PS D:\git\rebase-test\rep2cc> git filter-branch --parent-filter 'test $GIT_COMMIT = 443aec8880e898710796a1c4fb4decea1ca5ff66 && echo "-p 98e2b95e07b84ad1e40c3231e66840ea910e9d66" || cat' HEAD
fatal: ambiguous argument '98e2b95e07b84ad1e40c3231e66840ea910e9d66 || cat': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'
更新3:
它没有在Windows CMD工作或PowerShell,但它确实在Git Bash上运行。
那么,你有没有考虑过在同一个存储库中取得这两个数据,然后在另一个数据库上重新规划一个历史?这当然会重写所有提交历史的提交。 –
Lasse说得对。只要建立一个新的回购与svn克隆正确,添加一个远程这个捣毁回购,获取和樱桃选择正确克隆svn回购史上克隆从svn后完成的git。 – eftshift0
我是新的git,我刚刚得知我正在寻找的魔术字是'rebase' – lmcarreiro