So I looked into two possible options to do what you're looking for. One of them is to make a shallow clone of repo A
, but according to the documentation:
A shallow repository has a number of limitations (you cannot clone or fetch from it, nor push from nor into it), but is adequate if you are only interested in the recent history of a large project with a long history, and would want to send in fixes as patches.
Not being able to do basic network options like push and fetch from a shallow repo sounds like a pretty big limitation, so I think this next option might be better for you. Instead of making a shallow repo, you could try making an orphan branch starting at commit master~29
, then rebase commits master~28..master
on top of it:
git checkout --orphan root master~29
git add .
git commit -m "Add your message here"
That will start your orphan branch off, with a new root commit that contains the state of your history at commit master~29
. Next you'll want to rebase the descendant commits back on top (this will preserve history, except for the commit dates, which will necessarily be updated because of the rebase):
git rebase --preserve-merges --onto root master~29 master
# or `-p` for short
git rebase -p --onto root master~29 master
That will reconstruct the rest of master
on top of your new root, while also preserving any merge commits. If you want to confirm that this new version of master
is the same as the old one, just with a shorter history, then just do a diff immediately after the rebase:
git diff master@{1} master
I highly recommend that you test this one another clone first.