Scenario
Magento 1 is end of life. I want to migrate an existing Mage repo to the latest from Magento - Long Term Support Show archive.org snapshot maintained by OpenMage Show archive.org snapshot .
Warning: the following is based on my broken knowledge of git. Follow at your own risks.
Steps 1 and 2 Add a New Remote and Fetch
In local repo, add an upstream remote:
After clicking the Add/New Save button, continue to fetch from remote including tags.
Step 3 Create a New Branch
Step 4 Merge Mage-lts to the New Branch
git.exe merge --allow-unrelated-histories remotes/upstream/upstream-merge-1.9.4.3
Conflicts:
Step 5 Git Bash / TortoiseGit > Resolve
A Faster Way to Resolve Conflicts
The resolve method with TortoiseGit ver 2.8 takes too many hours. A faster way is to use Git Bash.
- Launch Git Bash in the directory where we want to resolve the conflict, this doesn't need to be the project root, but any sub-directory we want to resolve using a particular strategy. See StackOverflow - Git resolve conflict using --ours/--theirs for all files Show archive.org snapshot
- Use the command
grep -lr '<<<<<<<' . | xargs git checkout --theirs
to take the changes from upstream.
Error
kiat@win10 MINGW64 /d/Work/.../media (657_mage-lts|MERGING)
$ grep -lr '<<<<<<<' . | xargs git checkout --theirs
fatal: '--ours/--theirs' cannot be used with switching branches
The error seems to indicate that there is nothing to resolve in the folder. Nothing to worry about here.
Using TortoiseGit ver 2.8 is Too Slow, Do Not Use; Include for Reference
Go through the list of files and manually resolve the files that are specific to our application such as .gitignore, .htaccess, README.md
For the core files, select them in TortoiseGit Resolve window and mass resolve by right click and select Resolve conflict using "MERGER_HEAD (upstream/upstream-merge-1.9.4.3)"
The resolve process will take a while.
Step 6 Commit Our Works on Resolving Conflicts
Use VSCode to search for '<<<<<<<' to make sure we have resolve all the files.
I continue to use TortoiseGit to commit, click ignore something button (I don't remember the text) to ignore the "unresolved" files which appeared red and continue to commit. After, I pushed the committed branch to origin.
Step 7 Update master Branch
Before that, it's a good idea to switch to master, and create a new branch backupMasterBeforeLTS. If anything goes wrong, we can reset HEAD to it.
- [TortoiseGit] Push "657_mage-lts" branch to remote origin
- [TortoiseGit] Switch to master
- [TortoiseGit] Pull from origin to update local master
- [Git Bash]
git fetch origin
- [Git Bash]
git reset --hard origin/36_mage-lts
- [TortoiseGit]Push master to origin with option Force unknown changes
Step 8 Update staging Branch
As master is now updated, it's now easy to update staging. With TortoiseGit, switch to staging and merge master.
Done.