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. Excel输入公式后只显示公式却不计算如何解决?

    在使用Excel函数公式的时候,您是否碰到过输入公式,按下Enter键之后,单元格仍只显示公式,而不显示计算结果.   工具/原料   Excel 教程以Excel2013为例 方法/步骤     教 ...

  2. 第十三章 字符串(一)之 String

    这一节来学习String的特性和方法. 一.String对象的不变性 不变性:String对象是由一个final char[] value 数组实现的,因此String对象是不可变的.任何看起来改变S ...

  3. PAT B1012.数字分类

    全部AC #include <cstdio> int valid[5] = {0}; int count[5] = {0}; int p1(int i) { printf("%d ...

  4. HTML DOM focus() 方法

    目录 HTML DOM focus() 方法 实例 定义和使用 浏览器支持 语法 参数 技术描述 更多实例 实例 实例 HTML DOM focus() 方法 实例 为 <a> 元素设置焦 ...

  5. poj 1064 求解最大化问题

    对于二分而言,如果判断条件比较简单的话,在求解最大化或者最小化问题的时候就比较适用但是这道题目吖的卡精度.. #include<cstdio> #include<iostream&g ...

  6. O051、Create Volume 操作 (Part II)

    参考https://www.cnblogs.com/CloudMan6/p/5612147.html       1.cinder-scheduler 也会启动一个工作流 volume_create_ ...

  7. python之jupyter notebook

    jupyter是一种交互式计算和开发环境的笔记,ipython命令行比原生的python命令行更加友好和高效,还可以运行web版的界面,支持多语言,输出图形.音频.视频等功能. 安装 pip inst ...

  8. ES6入门二:默认值与默认值表达式

    默认值 默认值表达式 需要注意的是,这种默认值和默认表达式在IE的最新版本中仍然没有得到兼容,只能通过编译转码的方式降级到ES5使用. 一.默认值 在函数声明时可以给形参赋默认值,当调用函数时不传入或 ...

  9. JS中有两种自加法操作

    JS中有两种自加法操作.它们的运算符是++,它们的函数是向1添加运算符. 我和我的区别在于操作的顺序和组合的方向. 其中:++var被称为预自动添加,变量执行自动添加操作后.它的操作是先执行自动加法操 ...

  10. mintUI和mUI

    mintUI 安装: npm install mint-ui -S 引入: // 按需引入部分组件 import { Cell, Checklist } from 'mint-ui'; Vue.com ...