* How do I stop git enumerating my working directory
@ 2008-07-01 15:57 Paul Gardiner
2008-07-01 16:37 ` Matthieu Moy
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Paul Gardiner @ 2008-07-01 15:57 UTC (permalink / raw)
To: git; +Cc: lists
Hi,
I'm a recent convert to git. I've been swapping over my projects
from cvs to git. The latest candidate for conversion is the
config files for my Linux server. I've been using cvs to record
all the config changes, and - mostly-automatically - to setup
new servers. Git will do a far better job, I think, but
I think I'm going to run into a problem: the root directory
of the server will be the working directory. Only relatively
few files will be under version control. How do I stop git
enumerating the whole drive whenever I do things like git-diff?
I don't think I can make .gitignore files do the job, because
it seems that you can set up to ignore a whole directory,
and then partially countermand that by placing a .gitignore
file (containing ! commands) inside the directory. That
makes me think that ignoring doesn't prevent the
enumeration.
Any help most appreciated. I really want to use git for
this.
Cheers,
Paul.
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: How do I stop git enumerating my working directory
2008-07-01 15:57 How do I stop git enumerating my working directory Paul Gardiner
@ 2008-07-01 16:37 ` Matthieu Moy
2008-07-02 14:51 ` Paul Gardiner
2008-07-01 19:01 ` Brian Gernhardt
[not found] ` <c9e534200807011002q45ffca7bq8d91cd9b62335796@mail.gmail.com>
2 siblings, 1 reply; 5+ messages in thread
From: Matthieu Moy @ 2008-07-01 16:37 UTC (permalink / raw)
To: Paul Gardiner; +Cc: git
Paul Gardiner <lists@glidos.net> writes:
> I don't think I can make .gitignore files do the job, because
> it seems that you can set up to ignore a whole directory,
> and then partially countermand that by placing a .gitignore
> file (containing ! commands) inside the directory.
To me, it seems the opposite ;-).
I just tried to "git init" my $HOME, then "git status" takes forever,
but "echo '*' > .gitignore; git status" completes immediately.
So, an option is to put "*" in your .gitignore, and then "git add -f"
files explicitely, or to work your .gitignore finer.
--
Matthieu
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: How do I stop git enumerating my working directory
2008-07-01 16:37 ` Matthieu Moy
@ 2008-07-02 14:51 ` Paul Gardiner
0 siblings, 0 replies; 5+ messages in thread
From: Paul Gardiner @ 2008-07-02 14:51 UTC (permalink / raw)
To: Matthieu Moy; +Cc: git, lists
Matthieu Moy wrote:
> Paul Gardiner <lists@glidos.net> writes:
>
>> I don't think I can make .gitignore files do the job, because
>> it seems that you can set up to ignore a whole directory,
>> and then partially countermand that by placing a .gitignore
>> file (containing ! commands) inside the directory.
>
> To me, it seems the opposite ;-).
>
> I just tried to "git init" my $HOME, then "git status" takes forever,
> but "echo '*' > .gitignore; git status" completes immediately.
Ok, I was confusing myself because of having added files inside
subdirectories of the ignored directory. I'm glad it works the
way it does. Makes much more sense than what I'd thought it was
doing.
P.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: How do I stop git enumerating my working directory
2008-07-01 15:57 How do I stop git enumerating my working directory Paul Gardiner
2008-07-01 16:37 ` Matthieu Moy
@ 2008-07-01 19:01 ` Brian Gernhardt
[not found] ` <c9e534200807011002q45ffca7bq8d91cd9b62335796@mail.gmail.com>
2 siblings, 0 replies; 5+ messages in thread
From: Brian Gernhardt @ 2008-07-01 19:01 UTC (permalink / raw)
To: Paul Gardiner; +Cc: git
On Jul 1, 2008, at 11:57 AM, Paul Gardiner wrote:
> I don't think I can make .gitignore files do the job, because
> it seems that you can set up to ignore a whole directory,
> and then partially countermand that by placing a .gitignore
> file (containing ! commands) inside the directory. That
> makes me think that ignoring doesn't prevent the
> enumeration.
That's where you're wrong. You can't get git to pay attention to
anything inside an ignored directory using the .gitignore files. Once
you ignore a directory, git stops looking at it completely. You can
force git to look at a file inside an ignored directory by adding it
directly, though. Git will pay attention to files you add for
changes, but won't pay any attention to other files around it.
See the log below for what I mean:
$ mkdir temp
$ cd temp
$ git init
Initialized empty Git repository in /Users/brian/dev/temp/.git/
$ cat > .gitignore
ignoredir/
$ mkdir ignoredir
$ touch A
$ touch ignoredir/B
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# A
nothing added to commit but untracked files present (use "git add" to
track)
$ cat > ignoredir/.gitignore
!B
$ git status
# On branch master
#
# Initial commit
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# A
nothing added to commit but untracked files present (use "git add" to
track)
$ git add ignoredir/B
$ git status
# On branch master
#
# Initial commit
#
# Changes to be committed:
# (use "git rm --cached <file>..." to unstage)
#
# new file: ignoredir/B
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# A
$ git commit -m "A"
Created initial commit 36ade7a: A
0 files changed, 0 insertions(+), 0 deletions(-)
create mode 100644 ignoredir/B
$ echo new > ignoredir/B
$ git status
# On branch master
# Changed but not updated:
# (use "git add <file>..." to update what will be committed)
#
# modified: ignoredir/B
#
# Untracked files:
# (use "git add <file>..." to include in what will be committed)
#
# .gitignore
# A
no changes added to commit (use "git add" and/or "git commit -a")
^ permalink raw reply [flat|nested] 5+ messages in thread[parent not found: <c9e534200807011002q45ffca7bq8d91cd9b62335796@mail.gmail.com>]
* Re: How do I stop git enumerating my working directory
[not found] ` <c9e534200807011002q45ffca7bq8d91cd9b62335796@mail.gmail.com>
@ 2008-07-02 14:47 ` Paul Gardiner
0 siblings, 0 replies; 5+ messages in thread
From: Paul Gardiner @ 2008-07-02 14:47 UTC (permalink / raw)
To: Glenn Griffin, git, lists
Glenn Griffin wrote:
> On Tue, Jul 1, 2008 at 8:57 AM, Paul Gardiner <lists@glidos.net> wrote:
>> Hi,
>>
>> I'm a recent convert to git. I've been swapping over my projects
>> from cvs to git. The latest candidate for conversion is the
>> config files for my Linux server. I've been using cvs to record
>> all the config changes, and - mostly-automatically - to setup
>> new servers. Git will do a far better job, I think, but
>> I think I'm going to run into a problem: the root directory
>> of the server will be the working directory. Only relatively
>> few files will be under version control. How do I stop git
>> enumerating the whole drive whenever I do things like git-diff?
>
> I'm doing a similar thing in my home directory where the vast majority of files
> are not being tracked, but only a select few are. I've found that git
> automatically handles this case much better than other SCM's like subversion
> because of it's concept of the index. Most of git's commands wont enumerate
> your directory they will first read the index to see what files it's interested
> in, and then do an lstat on those files to see which if any have changed.
> git-diff in particular should do this to my knowledge. git-status is one of
> the few commands that will actually enumerate your directory to tell you which
> files are untracked, so long as you use status with care you will probably find
> you don't need to do anything special or even setup
> a .gitignore.
>
> Like I said, that's my experience your's may vary.
Brilliant! I've now tried it and it does just as you say. I don't
need git-status so it's just fine. Thanks for the advice.
P.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2008-07-02 14:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-07-01 15:57 How do I stop git enumerating my working directory Paul Gardiner
2008-07-01 16:37 ` Matthieu Moy
2008-07-02 14:51 ` Paul Gardiner
2008-07-01 19:01 ` Brian Gernhardt
[not found] ` <c9e534200807011002q45ffca7bq8d91cd9b62335796@mail.gmail.com>
2008-07-02 14:47 ` Paul Gardiner
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).