git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Definition of "the Git repository"

From
KBKevin Buckley <kevin.buckley@pawsey.org.au>
Date
Jun 28, 2021, 04:00 UTC
Message-ID
<ec31434f-0c99-ffb7-6eb0-6ecb1f6e761c@pawsey.org.au>
In-Reply-To
<60d9410bb07a1_aac5d20888@natae.notmuch>
On 2021/06/28 11:24, Felipe Contreras wrote:
Show 25 quoted lines
> Kevin Buckley wrote:
> 
>> Everything within the .git directory "belongs", in my way of thinking,
>> to the "repository", that is, the directory that gets created when git
>> is (init)ialised.
>> 
>> For me, the 'objects", the 'ref/heads', the "staging area' and the like,
>> also lie within the repository.
> 
> Does it?
> 
> Suppose you have three directories, each with exactly the same contents
> in their corresponding .git directory, the only difference is the
> .git/index file:
> 
>   a) No .git/index file at all
>   b) The .git/index file doesn't have anything staged
>   c) The .git/index file contains some staged changes
> 
> Do you really consider them three different repositories?
> 
> In my mind the staging area is where you put stuff in preparation for
> the commit. The commit is part of the repository, the staging area
> isn't.
> 

I think I do consider them as different, yes, but in the sense that, because the contents of any working directory can change in isolation to the others, they have become different instances (perhaps clones?) of the same repository.

Let's say I make two commits, that resulted in the same state of the files in the working directory, but I make them in different order in two of the working directories.

Clearly I need to sync the two different repositories in order to gain a consistency across them, and that suggets, to me, that they should be thought of as different.

Let's say I'd rsync-d one working directory, in which I'd made changes on its branch, with an unchanged one on a different branch (not that I'd recommend doing this without the utmost caution), then although the sync will not have affected the original branch in the unchanged directory, the git internals, stored in the .git repository, would have changed to reflect the new state.

As to the staging area,

again, for me, Git has an understanding of a "staging area" based on its inspection of the state of the working directory and a comparison of that state with what it knows has been committed.

Given that one can stash uncommited changes fron the "staging area", I think of both the "staging area" and various stashes as parts of the repository, in that you can't have a "staging area", unless there's a .git repository there to help instantiate the staging area".

Very much my perception of it all though: as others have pointed out, there does seem to be some wriggle room in how it is percieved.

Kevin
Previous: Felipe ContrerasNext: Felipe Contreras
Message 9 of 15 in “Definition of "the Git repository"”
  1. Kevin BuckleyJun 25, 2021
  2. Ævar Arnfjörð BjarmasonJun 25, 2021
  3. Igor DjordjevicJun 25, 2021
  4. Igor DjordjevicJun 25, 2021
  5. Felipe ContrerasJun 25, 2021
  6. Philip OakleyJun 25, 2021
  7. Kevin BuckleyJun 28, 2021
  8. Felipe ContrerasJun 28, 2021
  9. Kevin BuckleyJun 28, 2021
  10. Felipe ContrerasJun 28, 2021
  11. Kevin BuckleyJun 29, 2021
  12. Felipe ContrerasJun 29, 2021
  13. Philip OakleyJun 28, 2021
  14. Chris TorekJun 28, 2021
  15. Junio C HamanoJun 29, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.