I try to use git add -A
to keep git repo working directory same as staging area, but unfortunately, the .gitignore
file also add into the staging area. So how to recovery to make it untracked?
Asked
Active
Viewed 90 times
2

Marina Liu
- 36,876
- 5
- 61
- 74
-
2Possible duplicate of [How to remove a file from the index in git?](http://stackoverflow.com/questions/2223308/how-to-remove-a-file-from-the-index-in-git) – Ismail Badawi Oct 31 '16 at 07:44
-
3You *want* to track the ignore file, otherwise anywhere else you clone the repo to would not ignore the files it specifies. – jonrsharpe Oct 31 '16 at 07:44
-
Can you show us your `.gitignore`? – MD XF Oct 31 '16 at 07:45
1 Answers
5
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?

torek
- 448,244
- 59
- 642
- 775