How to get changes to files in a git repo while omitting new files
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
withgrep
orsed
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?
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.
Revised answer:
You will need some script that will walk through that directory and using each file get the initial commit with
git log --format=%H fileName | tail -1
And than get the diff with:
git diff ^output_of_above SHA_last_commit fileName
精彩评论