Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get changes to files in a git repo while omitting new files

Tags:

git

diff

I have a git repo with a folder that contains files that are auto-generated source code. Overtime, there were some slight manual modifications made to that code. I am now in a position where I need to regenerate the files but I don't want to miss any of the changes that were made.

What I'd like to do is get a diff of all changes made to that folder over time, but to exclude the original 'add' of each file. That way I could just apply the diff to the new set of files.

There is one more important detail: not all files were added at the same time. The adds are mixed in with the edits. So it's not as simple as generating a diff starting from a specific commit.

Any ideas?

MORE CONTEXT:

  • The auto generated files are SOAP proxy classes that are generated from WSDL files
  • We are dealing with more than one service and so the classes were added as they were needed.
  • We received an updated server VM with WSDLs that contain minor fixes
  • The tool used to generate the proxy classes has some incomplete implementations and so the changes made to those files were work arounds

SEEDS:

  • Is there a way to know the SHA of the first commit of a file? A flavor of git log with grep or sed I guess?
  • Perhaps get a count of commits on a specific file where 1 == no changes only an insert and I could grep those out?
like image 549
Sebastien Martin Avatar asked Nov 04 '22 15:11

Sebastien Martin


1 Answers

I'm assuming you still have the old copy of the WSDLs, being a good source control user and all. With that in mind, I would do the following:

  • Create and checkout a new branch from way back before any of the files in question were added.
  • Generate the classes using the old WSDLs and commit.
  • Generate the classes using the new WSDLs and commit.
  • Checkout master and merge the new branch in.

That will merge the differences of the auto-generated files with your manual tweaks.

Keep that branch around, so that every time the WSDLs change, you can check that branch out and repeat the last two steps. Basically, that branch should always contain only the auto-generated files.

like image 153
Karl Bielefeldt Avatar answered Nov 09 '22 09:11

Karl Bielefeldt