[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [gits] How does git really change one's directory view?



Ganesh Gopalakrishnan <ganesh@cs.utah.edu> writes:

> This is not advertised in git documentations I've seen but is "natural"
> behavior for git users. If you create a branch and populate it with files,
> those files are seen by "ls" when one checks out that branch. When one
> checkouts (say) master again, those files are not displayed by "ls".
>
> Who (or what mechanism) arranges this "directory view change" ? Does a git
> managed directory become essentially a pointer into a branch-specific
> directory structure in one's local repo?

I'm not sure exactly what part of git is responsible for manipulating the files
within the "working directory," but there is no magic involved.  By that I mean
that the files in the working directory are ordinary files, and the directories
are ordinary directories --- git just adds/removes files/directories to make
the working directory match the state of the commit that you have checked out,
according to its rules.

(And by "match" I don't mean exactly equal.  If for example you have a file
"foo.c" that git is not tracking, git will leave it alone when you checkout a
different branch or whatever.)

Am I answering the question that you were asking?

In some sense what you say is accurate: the state of the working directory does
reflect a directory structure that is represented within the repository.  But
the way you asked, it sounded as if you thought there might be some "funny
buiness" going on when you checkout a different branch --- and there isn't.

Eric.

-- 
-------------------------------------------------------------------------------
Eric Eide <eeide@cs.utah.edu>  .         University of Utah School of Computing
http://www.cs.utah.edu/~eeide/ . +1 (801) 585-5512 voice, +1 (801) 581-5843 FAX