In Git, I have two branch:
master
v2
v2
is a lerna mono repo,
I started the branch by removing the .git
directory, (this cause the whole history being lost), then I did git init; git remote add origin $url
in order to recreate a git history which I will push on v2
branch.
Now that the PR is almost ready to be merged, how can I merge in order to have v2
branch history placed on top of master
branch history?
What's the cleanest way to keep a good history?
Clone again your repository in another folder, while keeping the work you have done in your first folder (the one where you remove the .git
subfolder)
In that new local clone, switch to a new PR branch
git switch -c myNewPRBranch
Then import your work
git --work-tree=../old_repo add .
git commit -m "Import PR code"
git push -u origin myNewPRBranch
Finally, make a PR from your new PR branch to main
.
This assumes you can push directly to the cloned repository. If not, you would need to fork it first.