Is the Git staging area just an index?

后端 未结 5 2033
小鲜肉
小鲜肉 2021-02-07 00:01

The book Pro Git says that the staging area is just a list, or index, that says which files will be committed when a git commit is done, and now the name inde

5条回答
  •  猫巷女王i
    2021-02-07 01:03

    The staging area is not just a list, nor index, which says which files will be committed when a git commit is done.

    If it were that, i.e. a simple list, git add could never work as advertised.

    Rather, git add has to save the contents of the file at the time that the add command is given. So it snapshots files, and then puts these snapshots into the staging area, (aka 'the index', which IMHO is really a rather poor choice for a name).

    So yes, in fact, the book's statement is misleading and confusing. But this isn't too surprising. Much of the git documentation is confusing and poorly thought out.

    Go ahead and mark me down. I'm sure I'm right about this.

提交回复
热议问题