How to migrate to Magento LTS with git with combined histories

Updated . Posted . Visible to the public.

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:

Image

After clicking the Add/New Save button, continue to fetch from remote including tags.

Step 3 Create a New Branch

Image

Step 4 Merge Mage-lts to the New Branch

Image

git.exe merge --allow-unrelated-histories remotes/upstream/upstream-merge-1.9.4.3

Image

Conflicts:

Image

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.

  1. 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
  2. Use the command grep -lr '<<<<<<<' . | xargs git checkout --theirs to take the changes from upstream.

Image

Image

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)"

Image

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.

Image

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.

  1. [TortoiseGit] Push "657_mage-lts" branch to remote origin
  2. [TortoiseGit] Switch to master
  3. [TortoiseGit] Pull from origin to update local master
  4. [Git Bash] git fetch origin
  5. [Git Bash] git reset --hard origin/36_mage-lts
  6. [TortoiseGit]Push master to origin with option Force unknown changes

Image

Image

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.

Posted by kiatng to Git (2019-11-01 06:07)