David Konn
David Konn

Reputation: 29

Git exclude folder from pushing to repository

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?

Upvotes: 0

Views: 211

Answers (1)

Mark Adelsberger
Mark Adelsberger

Reputation: 45819

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

Upvotes: 1

Related Questions