Marina Marina - 1 month ago 6
Git Question

.gitignore is been tracked after use git add -A

I try to use

git add -A
to keep the working directory same with staging area, but unfortunately, the
.gitignore
file also add into the staging area. So how to recovery to make it untracked?

Answer

First, take it out of the staging area (to do so, follow the advice git status prints). Then simply add .gitignore as a line in the .gitignore file, so that you tell your Git not to add .gitignore to tracked files when you run git add.

It's unusual to want to avoid tracking the .gitignore file though. If it is important to tell Git not to add file foo.out, database.db, and so on, to the staging area, isn't it important to save the information that Git should not add these files to the staging area?