I have numerous Git repos with various scripts, and I’m in the process of merging them all into one. I want to preserve the commit history for each script, however.
I did this successfully, for the first repo, a couple of weeks ago, following the steps in this article. But when I tried just now for the next repo, the history doesn’t seem to be coming across.
I’ve changed the directory structure for the next repo, which I’ll call the ‘old repo’, to fit into the new all-in-one repo. I’ve committed that, and verified that the history is still attached to the script I want to merge.
Then I did this:
cd ../new-repo
git remote add -f old-repo ../old-repo
git fetch old-repo # I didn't do this the fist time I tried today
git merge old-repo/master --no-commit --allow-unrelated-histories
git log --follow bin/old-repo-script
The history didn’t appear; nothing did.
I’ve aborted the merge and tried again a few times, including:
- pointing a branch in the old repo to a commit with the script in the original location, and merging that
- creating a remote with an absolute path to the repo
- fetching the repo first (as shown above)
- checking out different branches in the old repo and then the master again, and then fetching it again
The script gets staged each time, but I don’t see its history, even though it still appears when I do a git log old-repo-script
in the old repo.
What might I be doing wrong today?
FWIW, I’m using Git version 2.34.1 under Linux.
1