The following command collects all of the untracked files within a git directory and moves them to .gitignore.
git status --porcelain | grep '^??' | cut -c4- >> .gitignore
The following command collects all of the untracked files within a git directory and moves them to .gitignore.
git status --porcelain | grep '^??' | cut -c4- >> .gitignore