`

git 三个重要的状态

    博客分类:
  • git
git 
阅读更多

 

git 三个重要的状态

The Three States 
Now, pay attention. This is the main thing to remember about Git if you want the rest of your learning process to go smoothly. Git has three main states that your files can reside in: committed, modified, and staged. Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot. 
翻译: 
现在请注意,假如你希望git接下来的学习更轻松更顺利,那么你必须记住下面的事情. 
Git 有三个重要的状态: 
1. 提交的; 
2. 修改的(未commit); 
3. 缓存的 
提交:表示你修改的数据已经安全的保存到了本地仓库; 
修改:你修改了文件,但是还没有提交到本地仓库; 
缓存:表示你已经标记了修改的文件作为下次commit的一部分, 
如果你不标记,那么下次commit的时候,就不会提交这个文件.

This leads us to the three main sections of a Git project: the Git directory, the working directory, and the staging area. 
翻译:git项目分为三个主要的部分: 
1. git本地仓库; 
2. 工作区; 
3. 缓存区 
git的三种状态

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.

The working directory 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.

The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit. It’s sometimes referred to as the “index”, but it’s also common to refer to it as the staging area.

The basic Git workflow goes something like this:

You modify files in your working directory.

You stage the files, adding snapshots of them to your staging area.

You do a commit, which takes the files as they are in the staging area and stores that snapshot permanently to your Git directory.

If a particular version of a file is in the Git directory, it’s considered committed. If it has been modified and was added to the staging area, it is staged. And if it was changed since it was checked out but has not been staged, it is modified. In Git Basics, you’ll learn more about these states and how you can either take advantage of them or skip the staged part entirely.

我们结合git的常用操作来体会下git的三个状态

git checkout –

git checkout – 实际上就是把修改的文件恢复到本地仓库的状态

git reset

git reset 把commit的内容回滚到本地仓库上次提交的状态

git add

git add就是把工作区的文件添加到缓存区 
git tree

 

0
1
分享到:
评论

相关推荐

    git reset 的三个参数.pdf

    在这个场景下,我们主要讨论`git reset`的三个参数:`--soft`、`--mixed` 和 `--hard`,以及它们在不同情况下的具体行为。 首先,让我们理解这三个参数的作用: 1. **--soft**: 当使用`git reset --soft`时,它...

    Git三件套,6666666666666666

    "Git三件套"通常指的是用于管理Git仓库的三个基本命令:`git clone`、`git commit`和`git push`。这三者是Git操作中最基础且重要的部分,对于理解和掌握Git工作流程至关重要。 1. **git clone**: `git clone`命令...

    git windows

    在Windows上安装Git,首先你需要访问Git官方网站或第三方提供者,找到适合你系统的安装包,如Git-1.8.1.2-preview20130201.exe。下载后,双击运行安装程序,按照向导提示进行操作。在安装过程中,你可以选择安装路径...

    git创建服务器端

    3. 分支:不同的开发线路,每个分支代表了代码的不同状态或功能。 4. 提交(Commit):保存对文件的更改,每个提交都有唯一的哈希值,记录了作者、时间戳和变更信息。 5. 远程仓库:存储在服务器上的Git仓库,用于...

    关于git的手册总结简单的git介绍,git的相关指令

    首先,Git有三个主要工作区域:工作区、暂存区(stage 或 index)和版本库。工作区是你在计算机上看到的目录,存放着你的文件和项目内容。暂存区则是Git用来存储即将提交更改的地方,通常位于`.git`目录下的`index`...

    git使用教程详细介绍

    Git 分支是 Git 的一个重要特性,它可以让开发者在不同的分支上工作,从而避免了代码冲突。Git 分支的管理包括何谓分支、分支的新建与合并、分支的管理、利用分支进行开发的工作流程等内容。 四、服务器上的 Git ...

    git零基础实战

    - Git对于个人的学习和发展、企业的版本控制至关重要。 #### 二、Git安装 - **Linux/Unix环境下安装** - 自动安装:适用于安装成熟稳定版本。 - Ubuntu/Debian:`sudo apt-get install git` - Fedora/Red Hat...

    基于狂神说的Git学习

    配置文件主要有三个级别:系统级(Git安装目录的gitconfig)、全局级(用户主目录的.gitconfig)和本地级(每个项目根目录的.gitconfig)。使用`git config`命令可以查看和修改这些配置,例如设置用户名和邮箱: ``...

    progit的手册

    工作目录、暂存区(stage)和仓库是Git的三个基本概念。Git通过快照而非差异来保存文件状态,这使得回溯历史变得简单且高效。 4. **自定义Git**(1-customizing-git.html): 用户可以通过配置文件(~/.gitconfig...

    git

    - 使用`git status`检查当前的状态。 - 使用`git add .`添加所有更改到暂存区。 - 使用`git commit -m "提交信息"`提交更改到本地仓库。 - 使用`git log`查看提交历史记录。 #### 七、远程仓库相关命令 1. **...

    使用gitlib搭建本地git服务器

    **第三步:配置gitblit.properties** 在解压后的Git目录下的"data"子目录中,你会找到`gitblit.properties`配置文件。使用记事本或其他文本编辑器打开此文件,进行以下关键配置: 1. `git.repositoriesFolder`:...

    git.docx个人自学笔记

    * Git 有三个主要区域:工作区(Working Directory)、暂存区(Staging Area)和版本库(Repository)。 * 工作区是指当前目录下的文件夹,暂存区是 Git 用来追踪文件变化的区域,版本库是 Git 管理文件的仓库。 二...

    git使用简介ppt

    ### Git使用简介及关键知识点 #### 一、Git介绍及其特点 **Git** 是一个开源的分布式版本控制系统,被广泛应用于软件开发过程中,用于高效...无论是对于个人开发者还是团队来说,掌握 Git 的使用方法都是非常重要的。

    Git介绍与使用-培训专用课程PPT

    Git的工作流程通常包括三个工作区:工作区(Working Directory)、暂存区(Index)和版本库(Repository)。开发者在工作区进行日常开发,修改的文件会被暂存到暂存区,待到满意时,将暂存区的改动一次性提交到版本...

    git 常用命令和示例

    每当您修改了代码,并希望将这些更改保存到版本库时,都需要经过这三个步骤。 #### 七、解决冲突 - **命令:** ```bash git stash git pull git stash apply git merge git add git commit ``` - **解释...

    Git权威指南.txt

    - 使用 `git commit` 命令为当前状态拍照,即创建一个新的提交。 - **10.2 文件的删除与恢复** - 在 Git 中删除文件实际上是将其标记为删除,真正的删除需要通过 `git rm` 命令完成。 - 如果误删文件,可以通过 ...

    git安装包和中文语言包.zip

    Git的本地仓库包含三个主要区域:工作目录(Working Directory)、暂存区(Stage/Index)和版本库(Repository)。工作目录是你直接编辑文件的地方,暂存区则用来临时保存你的修改,而版本库则记录了所有提交的历史...

    git知识点整理

    首先,Git的核心结构由三部分组成:工作区(Working Directory)、暂存区(Index / Stage)和版本库(Repository)。工作区是用户进行日常编辑的地方,而暂存区用于临时保存修改,版本库则存储所有提交的历史记录。...

Global site tag (gtag.js) - Google Analytics