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

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



Thanks, I did not mean "funny business", but the fact that a directory structure's semantics wrt various "unix commands" commands is altered the moment it becomes git-managed is something interesting and profound for me! 

And while I noticed it, I did not see any git documentation that explicitly discusses it. OK I guess it is the way people have accepted and moved on...  but the fact that there isn't explicit documentation is surprising. 

I began reading about "git fsck" to repair broken git repos, and such and then gave up, and said ... "forget it, I'll occasionally copy over my git managed repo to Google Drive" :-)

Cheers,

Ganesh

p.s. I guess people live in a perfect world where nothing bad happens J
(began reading this and stopped .. https://git-scm.com/book/en/v2/Git-Internals-Maintenance-and-Data-Recovery)











On Sat, Jul 8, 2017 at 9:40 PM, Eric Eide <eeide@cs.utah.edu> wrote:
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