Before the question, a bit of back story:
So basically I was doing some major renovation of the comments in a vast number of source files in one of my projects and added a quick description about each file as a comment at the top of the files (along with many comments within the code itself).
I then decided having gone through and done that, that I would add additional information in the descriptors - such as author, date etc. So living on the edge I decided to do a find and replace in files using regex to select the full contents of the file and replace it with some extra info in the headers keeping everything that used to be in the file. As I am working in Verilog, there is an endmodule
at the end of each file, so I used that as a marker to ensure I got everything in the regex.
Unfortunately, I forgot to add the endmodule
back into the replace string, so basically in some hundred or so source files, I lost the line at the end. Not too much of an issue, it was easy to find-replace to put them back. Lesson learnt.
Anyway, I didn't realise this at first, so I spend an hour or so grouping the source files into a series of commits to my github repository. Fortunately, I noticed the endmodule
issue before pushing those commits to origin, so I have been able to delete the commits using the git reset --soft HEAD~4
command to get rid of my 3 commits.
Now before I did that, I used the git show
command to get the commit descriptions and a list of files included in each commit which I have now got saved in a text file. I was hoping to use these to recreate the commits having put all of the endmodule
tags back.
But my powers of Google are letting me down this evening as I can't seem to find a way of making a commit containing all changes from a list of files. Ideally I would like some command I can run in the git shell (Windows Powershell) that will perhaps read a text file which contains a list of files. I then want all these files to be added to a new commit with the same message and extended description as before (these I can just copy and paste into whatever command).
Is there any way of doing this that is part of git, or do I need to get creative with powershell scripts?
I see from this SO question that you can use git commit [files]
to create a new commit of only specific files. I presume I can add the -m switch to add a message as is customary. But how pipe in a list of files to replace [files]
.
For now I have just taken my list, manually turned it into a line and pasted it in to the command which has worked for me. But as you can see from the image below, this is clear very ugly.
I'm sure there must be a neater way of doing this, so even though my problem is now fixed, I'd still like to know for future reference if it is possible to perform the command where the [files]
placeholder is replaced by the contents of a file which contains a filename on every line.