Skip to content

暂存区的一些思路 #19

Description

@keira-hq

https://img-blog.csdn.net/20160807164529000

  • 工作区(working directory)

  • 暂存区(staging area/index) git add .

    • 执行git add .命令
      • 将要提交的所有类型是文件的生成blob对象,放在objects中
      • 更新index.txt文件中的内容(首次commit,生成index.txt)
      • Index.txt中的每条索引记录的是blob对象的哈希值和其文件名
  • 仓库区(repository 本地仓库) git commit

    • 执行git commit
      • 生成index.txt中的所有索引的tree对象 Tree对象放入objects中
      • 根据最顶层的tree生成commit对象,并记录在head和对应的branch中
  • 一些操作命令示例:

    • git rm 时,把工作区中的这个文件以及暂存区中的这个文件索引都删除
    • git rm –cached 时,只把暂存区中的索引删去
    • git mv file2.txt file3.txt时,工作区中的文件被重命名(file2被重命名为file3),而索引区中的原file2的索引被删除掉了,然后重新添加了一条索引

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions