Re: Need help merging unrelated histories
- Date: Tue, 28 May 2019 13:26:34 -0500
- From: Robert Dailey <rcdailey.lists@xxxxxxxxx>
- Subject: Re: Need help merging unrelated histories
On Tue, May 28, 2019 at 8:35 AM Robert Dailey <rcdailey.lists@xxxxxxxxx> wrote:
> On Fri, May 24, 2019 at 12:11 PM Andreas Schwab <schwab@xxxxxxxxxxxxxx> wrote:
> > On Mai 24 2019, Robert Dailey <rcdailey.lists@xxxxxxxxx> wrote:
> > > Can anyone provide some advice on how to properly restructure this
> > > repository to create some ancestry, as if all along a `master` existed
> > > and all release branches were based on this in a linear fashion?
> > How about using git replace --graft, then git filter-branch to make it
> > permanent?
> I unfortunately have little-to-no experience with low level plumbing
> commands. Could you provide an example of a series of commands to run?
> It will help me to figure out how to do it on my own for my specific
> use case. Thanks in advance.
Toyed around with it a bit, and tried with the script below. There
were no errors, but I noticed that it erased my `.gitattributes` file
on master that I committed before performing the graft. Why did it
remove the file? I assume I'm not doing this correctly. Please advise.
if [[ ! -d Native_SDK.git ]]; then
git clone --bare git@xxxxxxxxxx:powervr-graphics/Native_SDK.git
rm -rf test_repo
git clone Native_SDK.git test_repo
git checkout -f --orphan new_master
echo '* text=auto' > .gitattributes
git add .gitattributes
git commit -m 'Add gitattributes file'
c=$(git log --oneline origin/3.4 | tail -1 | cut -d ' ' -f 1)
git replace --graft $c new_master
git filter-branch HEAD..origin/3.4
git merge --no-edit --no-ff origin/3.4