The 'Solution' below is rubbish: we can't have mirroring and lose the history. If we work from the orphan branch, mirroring fails because the branches we created have diverged from the upstream branches.
So, for both repos
- We'll set them up by creating in gitlab and pulling from upstream
- Delete the upstream branches we are'nt interested in (everything before lineage-17.1)
- We create our v1-d branch from the upstream lineage-17.1 branch, and make it our default branch
- We make our changes in the default branch. If upstream branches change, we will merge thos (manually) into our default branch
- To build for Z5 Compact (suzuran), we need proprietary files from an upstream repo
proprietary_vendor_sony. This has three device-specific directories
satsuki, and one shared directory
kitakami-common. My existing manifest puts this in the
- We only need the files from
kitakami-common, which will end up in
- We need the files to be in two separate repos, to avoid namespace problems when building other Sony devices, which also have vendor files in the
- We need to be able to easily (automatically in gitlab) mirror changes in the upstream repo
- We use two of the same branches as upstream. These branches diverged in October 2020. The last common commit before they diverged was commit
- We are not interested in history before the branches diverged
The problem in pictures (with less confusing names)
This is the structure in the upstream repo
`upstream-repo` - Device-1\ -- File-1 -- File-2 -- ... -- Sub-Dir-1 ---- File-3 ---- ... - Device-2\ -- ... -- File-3 -- ... - Device-3\ -- Files... - Shared-Files\ -- File-4 -- ...
This is the structure I want in the two new repos
`new-device-1-repo` - File-1 - File-2 - ... - Sub-Dir-1 -- File-3 -- ... `new-shared-files-repo` - File-4 - ...
Solution (Based on ideas from here)
- Clone upstream locally to a new local repo
orphanbranch from our starting commit
084827d, containing all the files in the repo at that point, but not staged or commited.
git reset --hard 084827d git checkout --orphan new-device-root
- Stage and commit all the files
git commit -am "Initial Commit from upstream commit 084827d"
- Make and commit the changes that we want in both of our new repositories: removing the devices we are not interested in
git rm -r device-2 git rm -r device-3 git commit -am "Remove devices 3 & 4"
- This is the point at which our new repos will diverge, so we will make a new copy of this repo for the other device
cd .. cp new-device-1-repo/ new-device-2-repo/ cd new-device-1-repo
- Remove Shared-Files directory
git rm -r Shared-Files git commit -am "Remove Shared-Files"
- Move Device 1 files to the top level
git mv device-1/* . git commit -am "Move device 1 files to top level"
- Delete our local copies of all the upstream branches
- Create empty local branches (with the same name) for the upstream changes we are interested in
- Pull / merge the upstream changes in each branch
- Repeat steps 6-10 in the
I have done a dry-run through this and it seems to work. There was one conflict one one of the branches which I was able to resolve. IRL, I will import the new repos into gitlab after step 8, to test out gitlab's mirroring functionality. I'll start with the branch without conflicts :)