Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

removing untacked file and directories with git/info/exclude

Tags:

git

gitignore

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
like image 632
ant2009 Avatar asked Nov 19 '12 03:11

ant2009


People also ask

How do I exclude a directory in git?

Repository exclude - For local files that do not need to be shared, you just add the file pattern or directory to the file . git/info/exclude .

How do I exclude files from a Git repository?

Open the . git/info/exclude file in a text editor and add the folder to ignore. This file remains private to you.

What is git info exclude?

git/info/exclude . This file is your own gitignore inside your local git folder, which means is not going to be committed or shared with anyone else. You can basically edit this file and stop tracking any (untracked) file.


1 Answers

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.

like image 179
mgarciaisaia Avatar answered Oct 05 '22 22:10

mgarciaisaia