Reputation: 9449
I have a Git project that was copied from another git project. It was just a file copy and commit, so it didn't copy history. I've since imported the commits from the previous files, but they aren't connected to the new versions of the file. So if I look for the history of a file that exists in both repos, history only goes to the time I copied the project across.
I tried checking out the last revision of the old project, and git merging the first revision of the new project. Then I merged to master. This makes the project's git history look right, but each individual's file history is unchanged.
It's almost like we want to delete the revision that says "create all these files" and instead prepend the old project's history.
Is this possible with Git?
Upvotes: 1
Views: 224
Reputation: 124646
It seems to me that you can rebuild the history with a fairly straightforward cherry-pick:
old
and new
pointing to the old and new repos respectivelyold/master
, which is at the last revision of the old repogit cherry-pick first..new/master
where first
is the SHA1 of the first commit in the new repo (you can find it with git log new/master
and press G
to jump to the end)The result will be basically the commits in the old repo + the commits in the new repo without first
. As usual with a cherry-pick, commit dates and authors will be preserved.
Upvotes: 1
Reputation: 1324278
prepend the old project's history. Is this possible with Git?
That should be possible, following this answer.
It uses git grafts
described in git repository layout, but that old answer could benefit from the more recent git replace
command.
See "Collating repositories or grafting earlier history with Git"
Upvotes: 2