1

Let's say I have a file files_to_stage.txt having file paths like

src/a/a1.txt
src/a/a2.txt
src/b/b3.txt
src/b/b6.txt
src/c/c5.txt

Now I want to stage all files having paths present in files_to_stage.txt for instance src/a/a1.txt, src/a/a2.txt etc.

How can I do it? I am looking for something like

git add -f files_to_stage.txt
Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
CodeTalker
  • 1,683
  • 2
  • 21
  • 31

1 Answers1

2
git add $(cat files_to_stage.txt)

should be enough.

The subcommand (the $() construct) reads out your file and sends it to git add.

Romain Valeri
  • 19,645
  • 3
  • 36
  • 61
  • 1
    Amazing.. Thanks :) Can't demand anything more. Sometimes we get so much obsessed with command flags that we forget wonders of shell :) Thanks for reminding me of that. – CodeTalker Feb 25 '21 at 10:42