I inherited a php project of 3rd party code with a good deal of company-specific customization lumped on top of it. Now I've got to upgrade it and the person who owned the project is the one I've replaced and no one else knows what changes are 3rd party changes and what changes are company specific.

It's not too terrible a situation because he did check in the initial version of the application from a few updates back. But then he checked in 2 or 3 updates and about 10 or 15 patches.

So, say I've got a completely generic 3rd party version from the company we bought the code from. How do I go about merging the changes the last developer made into a fresh version. We're using git.

closed as too broad by Bart van Ingen Schenau, durron597, GlenH7, Arseni Mourzenko, gnat Mar 30 '15 at 21:07

Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer. Avoid asking multiple distinct questions at once. See the How to Ask page for help clarifying this question. If this question can be reworded to fit the rules in the help center, please edit the question.


There's a few approaches you might consider:

  1. You could download a vanilla copy of the library from the same version as used in your project. Then use a diff utility to find what has been changed between your version and the vanilla version. This approach could work well if you know the version and there aren't too many changes.

  2. You could use git log to find commits affecting the directory containing the library then use that to determine what changes have been made. This won't work if you're not 100% certain that no changes were made before the library was initially committed.

  3. If you're really confident in your automated testing suite then you could try just swapping the libraries and seeing what fails. I wouldn't do this if you suspect there has been changes within the original methods of the library, but if only new methods have been added you'll probably find which are missing.

  4. If you're reasonably confident that the patches made since won't interfere with the changes then you could use git format-patch to generate a patch file for all the changes since your local version, then git apply to make those changes to your local copy.

While options 2 - 4 are probably more sophisticated, option 1 is probably what I'd end up doing most often.

  • Shoot, I was really hoping there would be come git magic, I'll have to see if I can scrounge up the version of the code he updated to. That's the hard part, I've only got bits and pieces. – Peter Turner Mar 27 '15 at 12:45
  • @PeterTurner you could probably put together some git magic using format-patch and apply as I mentioned, but if I had no idea what kind of changes had been made I'd be concerned that the patch would either break or overwrite the changes. – thexacre Mar 27 '15 at 12:51
  • I could give it a shot, but I think you're right about #1 being the safest route, especially since I have no experience with the codebase. I don't have any way of knowing if the previous maintainer made changes when he checked in service releases over the last two years. – Peter Turner Mar 27 '15 at 12:53

Not the answer you're looking for? Browse other questions tagged or ask your own question.