-2

When I git push my project, it doesn't ignore the "nbproject" directory although it's in the ".gitignore" file!

I tried :

git rm -r --cached nbproject

it stops tracking 'nbproject' in the next git push only, but it will be pushed again from the second push !!

Why does this happen ??!

Rowayda Khayri
  • 489
  • 1
  • 9
  • 21
  • 1
    What do you mean by "does not ignore"? `git push` does not look at the `.gitignore` file. – j6t Nov 27 '17 at 11:58
  • Possible duplicate of [How to make Git "forget" about a file that was tracked but is now in .gitignore?](https://stackoverflow.com/questions/1274057/how-to-make-git-forget-about-a-file-that-was-tracked-but-is-now-in-gitignore) – 1615903 Nov 27 '17 at 12:28
  • @j6t I mean that the "nbproject" directory was pushed to the git repo although it shouldn't be pushed as I put it in the ".gitignore" file – Rowayda Khayri Nov 28 '17 at 12:14
  • @1615903 No, I don't ask about that. I tried to make this and it remove "nbproject" from the repo, but it's pushed again on the next git push ! – Rowayda Khayri Nov 28 '17 at 12:16

1 Answers1

4

Use git rm -r --cached nbproject/ to stop tracking nbproject from the next commit (without deleting it).

.gitignore will not work on files that are already being tracked.

Edmund Dipple
  • 2,244
  • 17
  • 12
  • I tried this .. it stops tracking 'nbproject' in the next git push only, but it will be pushed again from the second push !! – Rowayda Khayri Nov 29 '17 at 13:55