Home > database >  Can Git track a file change and perform a three way merge?
Can Git track a file change and perform a three way merge?

Time:01-28

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.

CodePudding user response:

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)
  • Related