* Beginner problem with .gitignore
@ 2009-04-20 17:57 Kai Schlamp
2009-04-21 8:51 ` Michael J Gruber
0 siblings, 1 reply; 5+ messages in thread
From: Kai Schlamp @ 2009-04-20 17:57 UTC (permalink / raw)
To: git
Hello.
I have a file called TitleAreaDialog.java in the folder
my_path\org.eclipse.jface\src\org\eclipse\jface\dialogs
.git and .gitignore is in the my_path\ folder (using Git Cygwin on Windows).
Now I everything is ignored from org.eclipse.jface, but not that
TitleAreaDialog.java
So I specified the following in .gitignore:
/org.eclipse.*
!TitleAreaDialog.java
I also tried it with:
!Title*,
!/org.eclipse.jface/src/org/eclipse/jface/dialogs/TitleAreaDialog.java
but the TitleAreaDialog is always ignored as well.
What do I have to do to not ignore this file specifically?
Best regards,
Kai
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Beginner problem with .gitignore
2009-04-20 17:57 Beginner problem with .gitignore Kai Schlamp
@ 2009-04-21 8:51 ` Michael J Gruber
2009-04-21 9:57 ` Kai Schlamp
0 siblings, 1 reply; 5+ messages in thread
From: Michael J Gruber @ 2009-04-21 8:51 UTC (permalink / raw)
To: Kai Schlamp; +Cc: git
Kai Schlamp venit, vidit, dixit 20.04.2009 19:57:
> Hello.
>
> I have a file called TitleAreaDialog.java in the folder
> my_path\org.eclipse.jface\src\org\eclipse\jface\dialogs
>
> .git and .gitignore is in the my_path\ folder (using Git Cygwin on Windows).
>
> Now I everything is ignored from org.eclipse.jface, but not that
> TitleAreaDialog.java
>
> So I specified the following in .gitignore:
> /org.eclipse.*
> !TitleAreaDialog.java
>
> I also tried it with:
> !Title*,
> !/org.eclipse.jface/src/org/eclipse/jface/dialogs/TitleAreaDialog.java
>
> but the TitleAreaDialog is always ignored as well.
By "is ignored", do you mean that git status doesn't show it? git status
does not recurse into subdirectories by default unless there is at least
one tracked file inside.
>
> What do I have to do to not ignore this file specifically?
Have you ever added that file?
If you only want to track a few files it's easiest to ignore everything
and git add those files. Once added they will be tracked no matter what
the ignore patterns say.
Michael
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Beginner problem with .gitignore
2009-04-21 8:51 ` Michael J Gruber
@ 2009-04-21 9:57 ` Kai Schlamp
2009-04-21 11:43 ` Michael J Gruber
0 siblings, 1 reply; 5+ messages in thread
From: Kai Schlamp @ 2009-04-21 9:57 UTC (permalink / raw)
To: git
Michael, thanks for the help. Comments below.
> By "is ignored", do you mean that git status doesn't show it?
Yes, that is what I meant.
> git status does not recurse into subdirectories by default unless there
> is at least one tracked file inside.
Ok. I justed tested this a bit. Let's say I have the following directory
structure: "/a_dir/b_dir/c_dir"
And have a .gitignore with:
/a_dir
!/a_dir/b_dir/c_dir/
Now i put a file "a_file" in "c_dir".
And add the a_file with "git add /a_dir/b_dir/c_dir/a_file". Yes, a_file
is tracked now.
I would have expected (after your information above) that if I create
another file "b_file" in "c_dir" and check "git status" that this file
is on the untracked file list now.
But it doesn't show up.
And this makes it quite hard to exclude a whole folder, but only include
one of it's subfolders. I use git gui for commits. And I like it that
newly added files show up as untracked files.
But in this case those files in those subdiretories won't.
Best regards,
Kai
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Beginner problem with .gitignore
2009-04-21 9:57 ` Kai Schlamp
@ 2009-04-21 11:43 ` Michael J Gruber
2009-04-21 12:26 ` Kai Schlamp
0 siblings, 1 reply; 5+ messages in thread
From: Michael J Gruber @ 2009-04-21 11:43 UTC (permalink / raw)
To: Kai Schlamp; +Cc: Git Mailing List
Kai Schlamp venit, vidit, dixit 21.04.2009 11:57:
> Michael, thanks for the help. Comments below.
>
>> By "is ignored", do you mean that git status doesn't show it?
>
> Yes, that is what I meant.
>
>> git status does not recurse into subdirectories by default unless there
>> is at least one tracked file inside.
>
> Ok. I justed tested this a bit. Let's say I have the following directory
> structure: "/a_dir/b_dir/c_dir"
>
> And have a .gitignore with:
> /a_dir
> !/a_dir/b_dir/c_dir/
>
> Now i put a file "a_file" in "c_dir".
> And add the a_file with "git add /a_dir/b_dir/c_dir/a_file". Yes, a_file
> is tracked now.
>
> I would have expected (after your information above) that if I create
> another file "b_file" in "c_dir" and check "git status" that this file
> is on the untracked file list now.
That's for the case when you don't ignore that dir.
> But it doesn't show up.
> And this makes it quite hard to exclude a whole folder, but only include
> one of it's subfolders. I use git gui for commits. And I like it that
> newly added files show up as untracked files.
> But in this case those files in those subdiretories won't.
The problem is the recursive way in which git applies those patterns.
Your patterns above mean that git never recurses into the subdirs.
In the example above, you probably want
/a_dir/b_dir/*
!/a_dir/b_dir/c_dir/
Cheers,
Michael
P.S.: Please don't cull cc:
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Beginner problem with .gitignore
2009-04-21 11:43 ` Michael J Gruber
@ 2009-04-21 12:26 ` Kai Schlamp
0 siblings, 0 replies; 5+ messages in thread
From: Kai Schlamp @ 2009-04-21 12:26 UTC (permalink / raw)
To: git
> The problem is the recursive way in which git applies those patterns.
> Your patterns above mean that git never recurses into the subdirs.
>
> In the example above, you probably want
>
> /a_dir/b_dir/*
> !/a_dir/b_dir/c_dir/
Ok, I see. But that way would not ignore other directories in a_dir
beside b_dir. For that task I have to use the following in .gitignore:
/a_dir/*
!/a_dir/b_dir/
/a_dir/b_dir/*
!/a_dir/b_dir/c_dir/
This tends to a quite bloated .gitignore when you have a deep directory
structure and don't want to ignore all subfolders.
I also took a brief look into Mercurial and in my opinion the .hgignore
is more straightforward. It seems to use regexp on the complete file
path to find out if the files that should be ignored. So the above four
lines can be combined to one (and if the directory structure would be
deeper, it would also be just a one liner).
I know that there for sure is a reason for why git uses it's pattern in
.gitignore (probably a performance thing). But it would be nice to have
at least an option that it recurses into subdiretories, or uses regexp
syntax on the whole file path. Just my two cents.
Best regards,
Kai
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-04-21 12:28 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-04-20 17:57 Beginner problem with .gitignore Kai Schlamp
2009-04-21 8:51 ` Michael J Gruber
2009-04-21 9:57 ` Kai Schlamp
2009-04-21 11:43 ` Michael J Gruber
2009-04-21 12:26 ` Kai Schlamp
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).