Git的3个工作目录和4种状态

本文详细介绍了Git的3个工作目录(Git目录、工作目录、暂存区域)和4种文件状态(已提交、已修改、已暂存、未跟踪)。通过初始化仓库、克隆仓库和记录更改的步骤,阐述了Git的基本工作流程。同时,解释了如何使用git add和git commit命令将文件从未跟踪状态转移到暂存和提交状态。
摘要由CSDN通过智能技术生成

Git帮助手册

git命令全面介绍, 可以选择中文版阅读(不过有些内容有丢失, 如果能看懂原版, 建议看原版)

创建一个版本控制的文件, 用到的这些git指令, 可以对照着手册进行阅读

  • git init
  • git add
  • git commit
  • git push

今天尝试git commit, 提示我有untracked file
在这里插入图片描述
有些疑惑, 于是去查看了git帮助手册
在第一章1.3 git basics 中, 了解到了git的三种状态

  • committed(已提交)
  • modified(已修改)
  • staged(已暂存)
    下面看看手册中如何解释这三个状态
  • Committed means that the data is safely stored in your local database.
    committed意味着数据被安全的存储在你的本地数据库中
  • Modified means that you have changed the file but have not committed it to your database yet.
    modified意味着你已经改变了你的文件但是还没有把改变提交到你的数据库中
  • Staged means that you have marked a modified file in its current version to go into your next commit snapshot.
    staged意味着对一个已修改文件的当前版本做了标记,使之包含在下次提交的快照中。(个人理解, 就是修改的文件准备好要被提交(commit)了)

由此引入 Git 项目的三个工作区域的概念:Git 仓库(the Git directory,) 工作目录( the working tree)以及暂存区域(the staging area.)。
在这里插入图片描述

  • The Git directory is where Git stores the metadata and object database for your project. This is the most important part of Git, and it is what is copied when you clone a repository from another computer.
    git directory 是 Git 用来保存项目的元数据和对象数据库的地方。 这是 Git 中最重要的部分,从其它计算机克隆仓库时,拷贝的就是这里的数据。
  • The working tree is a single checkout of one version of the project. These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
    working tree(工作目录)是对项目的某个版本独立提取出来的内容。 这些从 Git 仓库的压缩数据库中提取出来的文件,放在磁盘上供你使用或修改。(我理解为自己电脑上本地磁盘上的文件)
  • The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. Its technical name in Git parlance is the “index”, but the phrase “staging area” works just as well.
    (staging area)暂存区域是一个文件,它保存了下次将提交(commit&
  • 3
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值