美文网首页
git日常操作流

git日常操作流

作者: 文千会 | 来源:发表于2017-10-20 22:40 被阅读0次

git的日常操作流workflow

先看git的三个’阶段’

working tree/working directory:可简单理解为本地副本。

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.

index/staging area:可简单理解为缓存区。

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.

repository:分为local repository(本地的版本库)和remote repository(远程仓库)由于第一章节所描述的分布式设计,每个人的电脑都是一个完整的版本库,所以俩者内容实质是一样的。

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.

三个阶段的简易联系

working tree ->git add->index , index->git commit->repository

再看git的四种文件状态

官方文档给出了git版本管理系统下的文件的各种状态,包括untracked(无迹可寻的)、unmodified(未修改的)、modified(修改的)、staged(进阶阶段之后的’)

git四种状态切换图.jpg

下面的这张图更清晰的描述了git各种操作指令对版本控制各状态的影响


git版本控制原理图.jpg

注意:

git fetch是从远程拉取代码到本地,只是拉取。

git rebase用于把一个分支的修改合并到当前分支。

git pull不仅拉取到本地还merge到本地分支中。所以git pull是git fetch与git merge的集合体。

git pull = git fetch + git merge

git pull --rebase = git fetch + git rebase

git checkout 所做的事情就是将命令行对应的版本库中或者index中的文件拷贝出来,粘贴到working directory(如果参数是版本库也会拷贝到index区域)区域中

备注

注意,不要将git所管理的文件的状态(untracked、unmodified、modified、staged)与git自身的阶段(working tree、index、local repository、remote repository)相混淆。

working directory中的文件可以包含多种状态,例如从版本库上一次提交snapshot检出的文件处于tracked和unmodified状态、本地对tracked文件的任何修改会使文件处于modified和staged(git add操作即可)状态,本地新增文件或其他操作会使得文件处于untracked状态

index中的文件只能处于modified和staged状态(同时处于);

repository(local or remote)中文件的状态只能处于unmodified的跟踪状态。
——当然这句话还有待考究,这里严格意义来说是从repository中检出的文件只能处于unmodified的tracked状态,因为你只能从别的仓库中将unmodified的tracked状态的文件拉倒本地。但原始的仓库中其实有可能存在着其他状态的文件,但是对外来讲是隐藏的、透明的。

本章完

相关文章

  • 复习:Git-HTML-CSS

    Git 曾做练习 相关理论 git工作流 git checkout 在日常的git操作中,git checkout...

  • git日常操作流

    git的日常操作流workflow 先看git的三个’阶段’ working tree/working direc...

  • Git第一步之Git提交

    基本操作 下文主要是写了日常Git提交和同步线上的一些日常操作 克隆 git clone <项目目...

  • 浅谈gitflow

    之前文章对git的日常操作做了简单的总结,本篇主要对gitflow进行说明和总结。 git日常的基本操作 Git ...

  • git常用命令

    以下git命令足以满足日常操作,如有错误请大家反馈。 倔强青铜git操作 利用git将本地项目上传到git远程仓库...

  • git操作与分支管理规范

    一、git操作规范 git操作流程数据流图 Remote:远程主仓库 Repository:本地仓库 Index:...

  • git 日常workFlow整理

    git 日常workFlow:常用的操作,并不涉及偏僻的操作、操作的比较,即:简单、高效 git管理项目,一般分为...

  • GIt 操作补充

    常用的git操作命令 常用的git操作命令已经能够满足日常的工作需求 现补充一些高级命令 git branch -...

  • Git常用命令

    相关资料:廖雪峰教程链接Git远程操作详解Git查看、删除、重命名远程分支和tag 操作流程 日常使用git更新提...

  • git 日常操作

    1、删除本地分支 强制删本地:git branch -D 分支名2、删除远程分支

网友评论

      本文标题:git日常操作流

      本文链接:https://www.haomeiwen.com/subject/ifjbuxtx.html