0

My repository consists of two folders client and server. In server I have few folders which were automatically generated by Codeblocks IDE like bin and obj. I dont want to store them in my repository, so I decided to add .gitignore. I tried everything:

# folders
**/bin/
**bin/
**/bin
**bin
bin
/bin
bin/
/bin/
server/bin
/server/bin
server/bin/
server/bin

And still after pull and making git status I can see that bin folder will be pushed. What am I doing wrong?

David Konn
  • 29
  • 4
  • How do the files appear in `git status`? – C-Otto Jan 16 '18 at 16:20
  • `new file: server/bin/Debug/chat server` `new file: server/obj/Debug/chat.o` – David Konn Jan 16 '18 at 16:23
  • 1
    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) – pishpish Jan 16 '18 at 16:23
  • Even if I use `git rm -r --cached .` and `git add .` the `bin` folder is still being tracked. – David Konn Jan 16 '18 at 17:21
  • @destroyer - Only a dup (of that quesiton) if the person asking realizes that the file was already tracked and that they're wanting git to "forget" the file. "Same answer" is not the same thing as "dup". – Mark Adelsberger Jan 16 '18 at 17:22
  • @DavidKonn - Why are you running `git add .` after the `git rm --cached` command? The `add` will undo the `rm`. – Mark Adelsberger Jan 16 '18 at 17:22
  • @MarkAdelsberger so I cant use `git add .`? I thought I can and `.gitignore` would take care of untracked files. – David Konn Jan 16 '18 at 17:34
  • @DavidKonn - Perhaps I misunderstood the procedure you're using; which is why I asked the question of why you ran the procedure you did. If you have ignore rules in place, then you can use `git add .`; it's not clear to me why you'd do that while trying to clean up your index. – Mark Adelsberger Jan 16 '18 at 20:32
  • @MarkAdelsberger "I can see that bin folder will be pushed" implies the files were added to the index, which means this _is_ a duplicate. – pishpish Mar 26 '18 at 13:56
  • @destoryer - Nope. "Same situation" or "same solution" does not make the QUESTION a dup. If the knowledge gap on the part of the person asking is different, it's not a dup. You and plenty of people around here would rather mark everything dup than actually answer questions, but that doesn't make it so. – Mark Adelsberger Mar 27 '18 at 14:54
  • Yeah, and same question makes it a duplicate. – pishpish Mar 27 '18 at 15:07

1 Answers1

1

In comments, you show that each file is listed as a "new file". You don't specify whether these show as "changes to be committed" or "untracked files"; but in the case of untracked files, if no files in a directory are tracked then only the directory (not the individual files) would be listed by default.

So it seems the problem is that files in these directories are in the index, which means git can't ignore them. You could remove them from the index

git rm -r --cached server/bin
git rm -r --cached server/obj
Mark Adelsberger
  • 42,148
  • 4
  • 35
  • 52
  • It says `fatal: pathspec 'server/bin' did not match any files`. What I noticed is when i change branch to `master` it is not tracking `bin` folder. After changing to my second branch it is tracking that folder. – David Konn Jan 16 '18 at 17:35
  • Now, in `.gitignore` I have `*.o`. I added new file `t.o` and when I use `git status` I can see, that this file is set as `untracked`. I think it should ignore this file. Ehh... – David Konn Jan 16 '18 at 17:55