1

Not sure three way merge is the correct terminology, so I will describe the capability.

Assume you're working on an MCU board library repository Raspberry PI B containing a file RPIB.h containing its pinouts and other definitions. A year later, a new MCU board is released called Raspberry PI B+. It is identical except its pinout is slightly different. As a result, you clone RPIB.h, renumber a few pins and name the file as RPIB+.h.

Is it possible for Git to track RPIB+.h and RPIB.h and apply changes to both? For instance, a bugfix in either file is merged into the other? This would make it difficult to forget applying the bugfix to both.

ATL_DEV
  • 9,256
  • 11
  • 60
  • 102
  • Git can detect (not track) renames, and it will not "duplicate" changes across "similar" files. – knittl Jan 24 '23 at 22:05
  • Thanks. This is odd as it's a fairly common use case. How is it normally handled, of at all? – ATL_DEV Jan 25 '23 at 01:10

1 Answers1

1

The use case—to keep multiple versions of software for different platforms—is extremely common, but the method you describe is very out of date and not how it is handled in modern development.

You wouldn't store multiple versions of the file with different names, you would store them on separate branches.

The correct procedure would be:

  1. Create a new branch for the B+
  2. Update the pins in the file on that branch
  3. Subsequent changes can then be made in your primary branch
  4. The primary branch can then be merged into the B+ branch (via a three-way merge)
LightBender
  • 4,046
  • 1
  • 15
  • 31
  • @ATL_DEV This, of course, assumes you want to use source control to manage multiple versions. From a wider perspective, this sounds more like an opportunity for abstraction than an issue for source control as you describe having a lot of repeated code. Consider breaking up the class and abstracting out the pin mappings, then you can compose as many versions as you need without duplicating any logic. – LightBender Jan 27 '23 at 11:13