我有一個在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