Git 1 - Getting Started

Git 的特点

  • Git 存储每个版本的快照;其他 VCS(版本控制系统) 存储两个版本的变化之处

    • 好处参考 Git 分支章节
  • Git 几乎所有操作都是本地的;其他 VCS 需要远程服务器
    • 这是因为 Git 在本地磁盘上有项目的整个历史.好处有两点,其一,访问速度很快;其二,断网时同样可以使用,upload 时再联网即可。
  • Git 具有完整性
    • store 之前,先进行 SHA-1 哈希算法校验,将检验和(40位16进制数)与其联系,所以每次修改 Git 都能知道。在 Git 数据库中不是以文件名存储,而是以它内容的哈希值存储。
  • Git 一般只 Add 数据,而不删除;其他 VCS,你可能丢失你没有 commit的数据
    • 更多关于 Git 如何存储数据,怎样恢复看似丢失的数据,请看 Undoing Things

三种状态(重点)

  • committed:数据安全存入本地数据库
  • modified:你修改了数据,但没有 commit 到本地数据库
  • staged:你已经标记了 modified 文件到当前版本,进入下一个 commit 快照

这把我们引向 Git 项目的三个主要 section:

  • Git directory: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 directory: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
  • staging area: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.

基本的 Git 工作流如下:

  1. You modify files in your working directory.
  2. You stage the files, adding snapshots of them to your staging area.
  3. 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’s modified but has been 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 Chapter 2, you’ll learn more about these states and how you can either take advantage of them or skip the staged part entirely.

Git 安装及配置

安装 msysGit (略),之后进行配置,主要是设置用户名和邮箱。

Git 自带工具 git config, 可以存储在三处:

  1. /etc/gitconfigfile: Contains values for every user on the system and all their repositories. If you pass the option --systemto git config, it reads and writes from this file pecifically.
  2. ~/.gitconfigor ~/.config/git/configfile: Specific to your user.You can make Git read and write to this file specifically by passing the --globaloption.
  3. config file in the Git directory (that is, .git/config) of whatever repository you’re currently using: Specific to that single repository.

优先级递增,如.git/config 会覆盖 /etc/gitconfig.

On Windows systems, Git looks for the .gitconfigfile in the $HOMEdirectory (C:\Users$USERfor most people). It also still looks for /etc/gitconfig, although it’s relative to the MSys root, which is wherever you decide to install Git on your Windows system when you run the installer.

pro git 读书笔记 1的更多相关文章

  1. Pro Git 读书笔记

    一. 起步 1. 集中式版本控制缺点:中央服务器的单点故障. 分布式版本控制优点:客户端并不只提取最新版本的文件快照,而是把代码仓库完整地镜像下来. 这么一来,任何一处协同工作用的服务器发生故障,事后 ...

  2. Pro Git读书笔记 - 分支

    Git 分支介绍. 几乎所有的版本控制系统都以某种形式支持分支. 使用分支意味着你可以把你的工作从开发主线上分离开来,以免影响开发主线. 在很多版本控制系统中,这是一个略微低效的过程--常常需要完全创 ...

  3. Pro Git读书笔记 - Git 常用命令

    在工作目录中初始化新仓库 要对现有的某个项目开始用 Git 管理,只需到此项目所在的目录,执行git init 检查当前文件状态 要查看哪些文件处于什么状态,可以用git status命令 将工作文件 ...

  4. pro git 读书笔记 3 Git 分支

    分支 新建分支:git branch 分支名 切换到该分支:git checkout 分支名 补充:以上两条语句等价于一句:git checkout -b 分支名 转换分支的时候最好保持一个清洁的工作 ...

  5. pro git 读书笔记 2

    Git 2 - Git Basics 1 add github 上建立新的 repository,命名 demo git clone 到本地 github 目录 将自己之前的项目 copy 到该 de ...

  6. 《Pro Git》笔记3:分支基本操作

    <Pro Git>笔记3:Git分支基本操作 分支使多线开发和合并非常容易.Git的分支就是一个指向提交对象的可变指针,极其轻量.Git的默认分支为master. 1.Git数据存储结构和 ...

  7. Pro Git 学习笔记

    Pro Git 学习笔记 文档地址:Pro Git原文地址:PRO GIT 学习笔记 git常见命令 1.Git起步 初次运行Git前的配置 用户信息 git config --global user ...

  8. 《Pro Git》笔记2:Git基础操作

    第二章 Git基础 Git基础包括:版本库的创建和获取,文件添加修改提交等基本操作,状态查询,远程版本库管理和同步,打标签. 1.取得项目的Git版本库 基于Git的工作流要以Git版本库为基础,即可 ...

  9. 《Pro Git》笔记1:起步

    第一章 起步 1.关于版本控制 版本控制用于记录和追踪目录结构和文件内容变化,能够追溯过去的任何修改和变化,并恢复到任何历史状态. 版本控制系统可以按照发展过程分成以下几类: 目录备份.记录版本变化最 ...

随机推荐

  1. mybatis报错无法扫描到xml文件

    错误:java.io.IOException: Could not find resource com/xxx/xxxMapper.xml 原因:target目录下没有***.xml文件 解决方法:在 ...

  2. oracle导出空表

    1.先查询数据库空表 select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0 ...

  3. JVM 和 GC

    一 堆与非堆 Java 虚拟机启动时创建一个堆,堆是运行时数据区域,所有类实例和数组的内存均从此处分配. 在JVM中堆之外的内存称为非堆内存.. 简单来说堆就是Java代码可及的内存,是留给开发人员使 ...

  4. Replication-Manager

    MYSQL5.7下搭建Replication-Manager 环境说明 在主机1,主机2,主机3上安装MySQL服务端和客户端. 主机1 主机2 主机3 操作系统 CentOS7.4 CentOS7. ...

  5. 并不对劲的复健训练-p3674

    题目大意 给出序列$ a_1,...,a_n $ ( $ n\leq10^5,a\leq 10^5 $ ),有\(m\) ( \(m\leq 10^5\))个以下三类询问: (1)给出\(l,r,k\ ...

  6. Hinton等人新研究:如何更好地测量神经网络表示相似性

    Hinton等人新研究:如何更好地测量神经网络表示相似性 2019年05月22日 08:39:15 喜欢打酱油的老鸟 阅读数 177更多 分类专栏: 人工智能   https://www.toutia ...

  7. Lua格式讲解

    firstValue = "This is a string value"; -- 这是一个变量的定义,变量定义不需要任何标记,这个是全局变量 print("helloW ...

  8. JS 正则验证字符串中是否含有数字

    var test_text="abc123";//2. if (new RegExp("[0-9]").test(test_text)) { return fa ...

  9. 1 C# 将对象序列化

    public static string ObjectToXml(object obj) { using (MemoryStream memoryStream = new MemoryStream() ...

  10. powershell查看版本信息

    在终端输入$PSVersionTable