8

Suppose I have a list of files (newline delimited) in a file, and I want to git add all these files.

Is there some way to do this directly?

I have checked online and looked at git help add, but did not see anything that helps.

merlin2011
  • 67,488
  • 40
  • 178
  • 299
  • @BrianRoach, I agree it is a more specific case of the other question, but when I was trying to solve this problem, the first thing that comes to mind is not to Google for "command line arguments from a file content". Therefore I think this question will still be beneficial for future seekers. – merlin2011 Mar 21 '14 at 21:18
  • Do this: https://stackoverflow.com/questions/4227994/how-do-i-use-the-lines-of-a-file-as-arguments-of-a-command/4229346#4229346. But, replace `some_command $line` with `git add $line`. – Gabriel Staples Feb 18 '20 at 08:01
  • Cancel that; use this answer instead! https://stackoverflow.com/questions/4227994/how-do-i-use-the-lines-of-a-file-as-arguments-of-a-command/60276836#60276836 – Gabriel Staples Feb 18 '20 at 08:45

1 Answers1

7

You can use xargs:

xargs -a file -d '\n' git add
John Kugelman
  • 330,190
  • 66
  • 504
  • 555