0

I'm trying to get my .gitignore to ignore everything except my src files in my NetBeans project. My gitignore looks like this

nbproject/private/
build/
nbbuild/
dist/
nbdist/
nbactions.xml
nb-configuration.xml

and its placed directly in the root directory of the netbeans project. Whenever i build/run in NetBeans, it always says theres uncommitted changes in Netbeans Project/build/built-jar.properties and Netbeans Project/dist/CodeEditor.jar, both of which should be ignored. (along with other .class files if i modify the source code). How do i get Github for Windows to ignore these files?

the git repo is located here https://github.com/Arhowk/fJass

Arhowk
  • 901
  • 4
  • 11
  • 22
  • that question is regarding the ignore structure in .git, mine is asking about why my .gitignore is not ignoring the files it should (it was retrieved from https://github.com/github/gitignore/blob/master/Global/NetBeans.gitignore) – Arhowk Jul 22 '14 at 20:51
  • 1
    It's the same problem. .gitignore isn't ignoring the files because it only affects untracked files. Since your build artifacts have already been added to Git (as evidenced by the fact that they show up on Github), they're not untracked. – David Jul 22 '14 at 21:31

1 Answers1

0

It looks like you probably added that file to the index at some point prior to adding it to the .gitignore file.

It's fairly easy to get yourself into this tight spot where git won't track the delete of the file (because it's already in the .gitignore!) - so the easiest way to achieve what you need is to:

  • Remove the specific file from the .gitignore file
  • Delete the file
  • Commit this deletion action
  • Add the line back into the .gitignore
  • Re-add your ignored file.

OR

git rm --cached filename and commit the change using git commit -m "msg" and you will be done.

progrenhard
  • 2,333
  • 2
  • 14
  • 14
  • I'm not trying to delete any file, I'm trying to stop it from syncing build artifacts. – Arhowk Jul 22 '14 at 21:19
  • @Arhowk have you looked at this ? http://stackoverflow.com/questions/1139762/ignore-files-that-have-already-been-committed-to-a-git-repository – progrenhard Jul 22 '14 at 21:23
  • 1
    @Arhowk, please actually read the other answers linked here and in the comments above. They explain your situation. You have files that are already tracked, so they cannot be ignored. `git rm --cached` can solve this for you. – ChrisGPT was on strike Jul 22 '14 at 22:34
  • git rm --cached all files commited you do not want to follow. Then git status will say that they have been deleted and it's normal. Git add --a and git commit. – damien marchand Jun 08 '16 at 14:56