Intially to ignore the untracked files permanently I ran a
git status --porcelain | grep '^??' | cut -c4- >> .gitignore
command. Now when I add a new file in my code, it is not showing in git status.
Intially to ignore the untracked files permanently I ran a
git status --porcelain | grep '^??' | cut -c4- >> .gitignore
command. Now when I add a new file in my code, it is not showing in git status.
You have overwritten your .gitignore with the data of your changed files. A git status --porcelain output has no meaning in the syntax of the .gitignore.
You need to recover your .gitignore. The simplest way is - assuming you had no local, not committed change to it - is
git checkout -- .gitignore
If you want to add your files anyway, you have several options :
git add -f file to disregard .gitignore and add the file anyway.gitignore file to remove the lines which should not be ignoredIf you want to undo the changes that were applied to .gitignore : just edit the file (with a text editor).
[anycommand] >> .gitignore just adds the output of [anycommand] at the end of the file ;
you should be able to spot the section with all the files listed by :
git status --porcelain | grep '^??' | cut -c4-
and just delete that section.
You should probably modify your .gitignore file anyway, it is not very conventional to ignore a long list of specific files.
if you really want to ignore every untracked file (current and future), set your .gitignore to :
# ignore everything
*
you can still add new files using git add -f
if you want to ignore specific folders, just name those folders :
# ignore the "tmp/" and "build/" directories :
tmp/
build/
For an extensive documentation : see git help ignore