Denis Denis - 5 months ago 34
Git Question

how to add all currently untracked files/folders to git ignore?

I initialized the

repository and made a first commit.
Now, in this directory I run
./make all
so that it populates a lot of extra files/folders don't want to track.

What I would like to do, is to add all those untracked files once and for all to my gitignore. Is there any simple way to do it?

I can get rid of some unnecessary files like
by specifying appropriate lines in .gitignore, but this does not solve the problem.


Try this:

git status -s | grep -e "^\?\?" | cut -c 4- >> .gitignore

Explanation: git status -s gives you a short version of the status, without headers. The grep takes only lines that start with ??, i.e. untracked files, the cut removes the ??, and the rest adds it to the .gitignore file.