ファイルリストを "git add"にパイプします。

ファイルリストを

新しい複製を実行し、作業ディレクトリを複製されたディレクトリにコピー/貼り付けました。これで変更されたファイルのリストが表示されます。

$ git status --short | grep -v "??" | cut -d " " -f 3 
GNUmakefile
Readme.txt
base32.h
base64.h
...

Gitに追加しようとするとエラーが発生します(一度に1つずつ追加することは気にしません)。

$ git status --short | grep -v "??" | cut -d " " -f 3 | git add
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

次に追加-:

$ git status --short | grep -v "??" | cut -d " " -f 3 | git add -
fatal: pathspec '-' did not match any files

そして--

$ git status --short | grep -v "??" | cut -d " " -f 3 | git add --
Nothing specified, nothing added.
Maybe you wanted to say 'git add .'?

試してみてくださいインタラクティブマニュアルページを見ると、状況がさらに混乱するようです。

$ git status --short | grep -v "??" | cut -d " " -f 3 | git add -i
           staged     unstaged path
  1:    unchanged        +1/-1 GNUmakefile
  2:    unchanged      +11/-11 Readme.txt
  ...

*** Commands ***
  1: status   2: update   3: revert   4: add untracked
  5: patch    6: diff     7: quit     8: help
Huh (GNUmakefile)?
What now> *** Commands ***
  1: status   2: update   3: revert   4: add untracked
  5: patch    6: diff     7: quit     8: help
Huh (Readme.txt)?

(私はGitがめちゃくちゃにしたディレクトリをすでに削除しているので修正したくありません。)

パイプでリンクされたファイルを追加するようにGitにどのように指示しますか?

ベストアンサー1

git addファイルがパイプライン化されるのではなく、パラメーターとしてリストされると予想されますstdin

git status --short | grep -v "??" | cut -d " " -f 3 | xargs git add

または

for file in $(git status --short | grep -v "??" | cut -d " " -f 3); do
    git add $file;
done

おすすめ記事