Stage `git status` output in one go.
Here is a nice little command to stage multiple modified files in a Git project in one go.
git add $(git status -s | cut -c 4-)
The -s
flag tells the status sub-command to output the results in short-format giving us a letter or "??" to indicate the file status followed by the filename. The cut command allows us to "remove sections from each line of files" but handles piped input too. The -c 4-
flag tells it to keep from only the 4th character on each line to the line end.
Doing that removes the extra white-space and the status indicator at the start of each line thus giving output suitable for git add
.