tags:

views:

396

answers:

4

I'm new to git so please be gentle.

I had a clean working directory and done a clone from a repo last night.

But my local server created a stats folder which I want to ignore. But I can seem to get git to ignore this folder when i run a git status.

See the status message

I added in my .gitignore a few different lines but it still trying to add them ie.

public_html/stats
public_html/stats/**
public_html/stats/**/*
public_html/stats/*

But it's still trying to add them.

Hope you can advise and thank you in advance.

+4  A: 

Try /public_html/stats/* ?

But since the files in git status reported as to be commited that means you've already added them manually. In which case, of course, it's a bit too late to ignore. You can git rm --cache them (IIRC).

Michael Krelin - hacker
I already tried that
Lee
Wait! You have "files to be committed" — that means you've already `git add`-ed them.
Michael Krelin - hacker
Ive done a git rm now and seems to be fixedThanks you All
Lee
A: 

Try putting a .gitignore file into the public_html directory, and just adding

stats

to that file.

Also, try looking here if you haven't already, or look at the manpage by typing man gitignore.

Matt Ball
+1  A: 

From "git help ignore" we learn:

If the pattern ends with a slash, it is removed for the purpose of the following description, but it would only find a match with a directory. In other words, foo/ will match a directory foo and paths underneath it, but will not match a regular file or a symbolic link foo (this is consistent with the way how pathspec works in general in git).

Therefore what you need is

public_html/stats/

kajaco
That just means "public_html/stats/" will only match a directory, but not a file, but "public_html/stats" will match both the directory and a file of that name, so that's not the issue. Still a good idea though.
jmanning2k
The man page says foo/ will match a directory foo and paths underneath it. OP wants to ignore the folder and its contents. Aside from other issues with git add, this is how it's done.
kajaco
+1  A: 

It's /public_html/stats/*.

leethal ~/foo [?]> ls public_html/stats/
bar baz foo
leethal ~/foo [?]> cat .gitignore 
public_html/stats/*
leethal ~/foo [?]> git status
# On branch master
#
# Initial commit
#
# Untracked files:
#   (use "git add <file>..." to include in what will be committed)
#
#   .gitignore
nothing added to commit but untracked files present (use "git add" to track)
leethal ~/foo [?]>
August Lilleaas