私はsvnリポジトリに3年以上の履歴を持つプロジェクトを持っています。これはgitに移行されましたが、これをやった人は、最後のバージョンをとり、これらの3年間の歴史をすべて破棄します。ルートコミット親を別のコミット(2つの独立したgitリポジトリを接続する)を指すように変更します
プロジェクトは過去3〜4ヶ月の履歴を1つのリポジトリに持ち、残りの3年間のsvn履歴を新しいgitリポジトリにインポートしました。
2番目のリポジトリのルートコミットを最初のコミットに最後にコミットする方法はありますか?
* 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コードのようなコミット日付を考えてみましょう...--parent-filter
ののオプションで、git rebase
ではなくgit filter-branch
を使用していました。
アップデート2:
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:私はコマンドgit filter-branch --parent-filter 'test $GIT_COMMIT = 443aec8880e898710796a1c4fb4decea1ca5ff66 && echo "-p 98e2b95e07b84ad1e40c3231e66840ea910e9d66" || cat' HEAD
を試み、それが動作しませんでした
これは、WindowsのCMD上で動作しませんでしたかPowerShellは、WindowsのGit Bashで動作しました。
さて、同じリポジトリ内で両方をフェッチしてから別のものの上に1つの履歴をリベースすると考えましたか?これはもちろん、リベースしている履歴のすべてのコミットを書き換えます。 –
ラッセはそれを正しく得た。ちょうどsvnでクローンされた新しいリポジトリをセットアップし、この破棄されたリポジトリをリモートに追加し、フェッチし、チェリーピックアップして、svnから複製した後にgitで行われた履歴を正しくクローンされたsvnリポジトリに入れます。 – eftshift0
私はgitで新しいです、私はちょうど私が探していた魔法の単語が 'rebase'であることを学ぶ – lmcarreiro