.gitignore not works, not ignoring

150 views
Skip to first unread message

Andrzej Borucki

unread,
Apr 24, 2013, 10:09:07 AM4/24/13
to msy...@googlegroups.com
Hi
I am Polish programmer, I am beginner in Git. I created repository and have init it with  two files: README.md and .gitignore.
Repository is for Pascal files, in .gitignore I have:*.~*~
When I copy file parse.~pas and type "git status" it show this file parse.~pas is untracked
When I type "git add ." and "git status" it show this file parse.~pas is new
I search answer in internet with Google but I found only:
git rm -r --cached .
git add .
git commit -m "fixing .gitignore"
But it not works correctly
How ignore files? It is a git bug or feature?
Thanks for advice

Konstantin Khomoutov

unread,
Apr 24, 2013, 12:36:31 PM4/24/13
to Andrzej Borucki, msy...@googlegroups.com
On Wed, 24 Apr 2013 07:09:07 -0700 (PDT)
Andrzej Borucki <borucki...@gmail.com> wrote:

> and have init it with two files: README.md and .gitignore.
> Repository is for Pascal files, in .gitignore I have:*.~*~

^^^ This pattern looks botched to me.
Did you compose your message using the Google Groups web interface?

> When I copy file parse.~pas and type "git status" it show this file
> parse.~pas is untracked
> When I type "git add ." and "git status" it show this file parse.~pas
> is new I search answer in internet with Google but I found only:
> git rm -r --cached .
> git add .
> git commit -m "fixing .gitignore"
> But it not works correctly
> How ignore files? It is a git bug or feature?
> Thanks for advice

Works for me, observe:

C:\tmp>mkdir foo

C:\tmp>cd foo

C:\tmp\foo>git init
Initialized empty Git repository in C:/tmp/foo/.git/

C:\tmp\foo>touch test.~pas

C:\tmp\foo>git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# test.~pas
nothing added to commit but untracked files present (use "git add" to track)

C:\tmp\foo>cat >.gitignore
*.~pas
^Z

C:\tmp\foo>type .gitignore
*.~pas

C:\tmp\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)

C:\tmp\foo>git --version
git version 1.8.1.msysgit.1

Johannes Schindelin

unread,
Apr 24, 2013, 12:41:13 PM4/24/13
to Andrzej Borucki, msy...@googlegroups.com
Hi Andrzej,

On Wed, 24 Apr 2013, Andrzej Borucki wrote:

> in .gitignore I have:*.~*~
> When I copy file parse.~pas and type "git status" it show this file
> parse.~pas is untracked

That would match the pattern "*.~*" but not "*.~*~" because the file name
does not have a trailing tilde.

Ciao,
Johannes

Andrzej Borucki

unread,
Apr 24, 2013, 1:42:37 PM4/24/13
to msy...@googlegroups.com, Andrzej Borucki

W dniu środa, 24 kwietnia 2013 18:41:13 UTC+2 użytkownik Johannes Schindelin napisał:
That would match the pattern "*.~*" but not "*.~*~" because the file name
does not have a trailing tilde.

Thanks all !
I search problems in git and not in .gitignore because I think that .gitignore is correct - this file is from github, standard for Delphi
In https://github.com/github/gitignore/blob/master/Delphi.gitignore need fix

Konstantin Khomoutov

unread,
Apr 24, 2013, 2:05:45 PM4/24/13
to Andrzej Borucki, msy...@googlegroups.com
On Wed, 24 Apr 2013 10:42:37 -0700 (PDT)
Andrzej Borucki <borucki...@gmail.com> wrote:

[...]
> > That would match the pattern "*.~*" but not "*.~*~" because the
> > file name does not have a trailing tilde.
> >
>
> Thanks all !
> I search problems in git and not in .gitignore because I think that
> .gitignore is correct - this file is from github, standard for Delphi
> In https://github.com/github/gitignore/blob/master/Delphi.gitignore
> need fix

Well, let's reiterate.
The glob pattern "*.~*~" would match "foo.~pas~" but it won't match
"foo.~pas" because this pattern *requires* a tilde character as the
last character in the file name, which in your case was not there.

Andrzej Borucki

unread,
Apr 25, 2013, 3:25:01 AM4/25/13
to msy...@googlegroups.com
.gitignore works very well - I don't must commit gitignore to apply changes, only modify file - it is fantastic.
But, is is possible to have more than one .gitignore file, second in other directory?
For example - I have project most in Pascal, but in one directory is Visual C++ sources, I wanna local gitignore because if I have many languages, several extension in one language I want to ignore, but in other language - not

Konstantin Khomoutov

unread,
Apr 25, 2013, 6:08:16 AM4/25/13
to Andrzej Borucki, msy...@googlegroups.com
.gitignore files are per-directory -- see the second bullet in [1],
and also in [2] for instance.

P.S.
Please bear in mind that this mailing list is dedicated to discussion
of the *development* of Git for Windows, and bugs/problems which are
specific to this port. Please direct generic questions about Git to
the git-users mailing list or (with hard-core questions) to its main
mailing list. See [3] for more info.

1. https://www.kernel.org/pub/software/scm/git/docs/gitignore.html
2. https://help.github.com/articles/ignoring-files
3. http://git-scm.com/community
Reply all
Reply to author
Forward
0 new messages