ant2009
ant2009

Reputation: 22486

removing untacked file and directories with git/info/exclude

git version 1.7.11.7
Fedora 17

Hello,

I create a new git working resposity

git init

I added some files and some directories.

However, I have some files that I want to ignore based on my environment. I don't want to create a .gitignore file as I don't want it added to repository. Just my local.

So I want to ignore my server/build directory so I added it to my .git/info/exclude file.

# exclude patterns (uncomment them if you want to use them):
 *.[oa]
 *~
 server/build

server is the root directory where I init my git resposity.

However, when I do git status I always get this directory in my untacked files.

# On branch dev
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
server/build/

I want to remove this from my git status.

I have tried the following with didn't work for me

git rm -r --cached server/build

Upvotes: 6

Views: 8422

Answers (1)

mgarciaisaia
mgarciaisaia

Reputation: 15540

You're leaving a blankspace before the pattern. Delete it and it should work:

# exclude patterns (uncomment them if you want to use them):
*.[oa]
*~
server/build

If your repo doesn't have a .gitignore you could create one and ignore itself, too - but it really is more correct to use exclude, anyway.

Upvotes: 6

Related Questions