DEV Community

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

Collapse
 
sethiadhira profile image
sethiadhira • Edited

True, when you rename the file, eventually file does not exist hence the renamed file is not considered.
I added a small if-else(just for renamed files) in the above statement to make it work for my use case.

git status --porcelain=v1 | awk {' if ($1 == "R") print $4 ; else print $2'} | xargs -I {} cp -r {} modified_files/

Thread Thread
 
grepliz profile image
Liz Lam

Ah I see. You are actually doing a git mv to rename your files. Yes, you are right, in that case your solution is perfect! Thanks for sharing!