powershell - git shell (windows) add list of files to new commit -
before question, bit of story:
so doing major renovation of comments in vast number of source files in 1 of projects , added quick description each file comment @ top of files (along many comments within code itself).
i decided having gone through , done that, add additional information in descriptors - such author, date etc. living on edge decided find , replace in files using regex select full contents of file , replace info in headers keeping used in file. working in verilog, there endmodule @ end of each file, used marker ensure got in regex.
unfortunately, forgot add endmodule replace string, in hundred or source files, lost line @ end. not of issue, easy find-replace put them back. lesson learnt.
anyway, didn't realise @ first, spend hour or grouping source files series of commits github repository. fortunately, noticed endmodule issue before pushing commits origin, have been able delete commits using git reset --soft head~4 command rid of 3 commits.
now before did that, used git show command commit descriptions , list of files included in each commit have got saved in text file. hoping use these recreate commits having put of endmodule tags back.
but powers of google letting me down evening can't seem find way of making commit containing changes list of files. ideally command can run in git shell (windows powershell) perhaps read text file contains list of files. want these files added new commit same message , extended description before (these can copy , paste whatever command).
is there way of doing part of git, or need creative powershell scripts?
i see so question can use git commit [files] create new commit of specific files. presume can add -m switch add message customary. how pipe in list of files replace [files].
for have taken list, manually turned line , pasted in command has worked me. can see image below, clear very ugly.

i'm sure there must neater way of doing this, though problem fixed, i'd still know future reference if possible perform command [files] placeholder replaced contents of file contains filename on every line.
try (gc .\files.txt) -join ", " read lines file , return them comma separated list. nest part of git commit:
edit - surround each file path in double quotes , separate space instead of comma (sorry, didn't think straight), based on suggestion:
("""$((gc .\files.txt) -join '" "')""") alternatively use % { } (the foreach-object cmdlet script block) on array before joining it.
(gc .\files.txt | % {'"{0}"' -f $_}) -join " " to make final git command:
git commit ("""$((gc .\files.txt) -join '" "')""") -m "message" -m "extended description"
Comments
Post a Comment