DEV Community

Discussion on: Copy Your Modified Files in Git with 1 line

Collapse
 
grepliz profile image
Liz Lam

Yeah, I feel like a lot of people come up with different solutions for this same problem. What is your command? It's always good to see different options.

Collapse
 
basuradeluis profile image
basuradeluis • Edited
tar cvf newFilename.tar `git status -s`

As I see now, "status -s" is similar to "status --porcelain".
My comand does not skip first column, so it will try add files "??" or "M" to the new .tar file, it will fail (and show a warning/error) as it will not find them, but it will continue with the other arguments.

Basically it is
tar cvf newFile.tar [list of file names separated with spaces]

DISCLAIMER TO EVERYBODY: my command is dirty and not tested. I dont take any responsability of anyone using it. Learn "tar cvf" and `` before using it :-)

Thanks for sharing, Liz, maybe i will try yours and/or the awk comand. Thanks

Thread Thread
 
grepliz profile image
Liz Lam

Ah I see you. Yes, you can do something similar like this:
git status -s | awk {'print $2'} | xargs -I {} tar -cvf newfile.tar {}

Thanks for sharing!