NOTES ON GIT PRO CH1 GETTING STARTED

1.1  Getting Started - About Version Control

What is a Version Control System(VCS)?

a system that records changes to a file or set of files over time so that you can recall specific versions later.

  • to revert files back to a previous state, 
  • revert the entire project back to a previous state, 
  • compare changes over time, 
  • see who last modified something that might be causing a problem, 
  • who introduced an issue and when, 
  • and more

历代VCS实例特  点
Local VCSRCS(Mac OS X)a simple database that kept all the changes to files under revision control
Downside:whenever you have the entire history of the project in a single place, you risk losing everything.
Centralized VCSCVS, Subversion, and Perforcehave a single server that contains all the versioned files, and a number of clients that check out files from that central place.

Downsidethe single point of failure that the centralized server represents;whenever you have the entire history of the project in a single place, you risk losing everything.
Distributed VCSGit, Mercurial, Bazaar or Darcsclients don’t just check out the latest snapshot of the files: they fully mirror the repository. Every clone is really a full backup of all the data.you can collaborate with different groups of people in different ways simultaneously within the same project


1.2 Getting Started - A Short History of Git

1.3 Getting Started - Git Basics

Git: Every time you commit, or save the state of your project in Git, it basically takes a picture of what all your files look like at that moment and stores a reference to that snapshotGit thinks about its data more like a stream of snapshots.

Contrast: other VCSs think of the information they keep as a set of files and the changes made to each file over time.


Nearly Every Operation Is Local

the gods of speed,doesn’t need to go out to the server to get the history and display it for you, very little you can’t do if you’re offline or off VPN

Git Has Integrity

Everything in Git is check-summed before it is stored and is then referred to by that checksum. 

 SHA-1 hash,40-character string composed of hexadecimal characters (0–9 and a–f) 

Git Generally Only Adds Data

after you commit a snapshot into Git, it is very difficult to lose

The Three States

Git has three main states that your files can reside in: 

committed,  the data is safely stored in your local database

modified, have changed the file but have not committed it to your database yet.

staged. you have marked a modified file in its current version to go into your next commit snapshot


three main sections of a Git project: 

the Git directory,  where Git stores the metadata and object database for your project

the working tree, a single checkout of one version of the project. placed on disk for you to use or modify.

the staging area. a file, generally contained in your Git directory, that stores information about what will go into your next commit. 


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.


1.4 Getting Started - The Command Line

the command line is the only place you can run  all  Git commands


1.5 Getting Started - Installing Git

sets up solid credential caching and sane CRLF settings.You can download this from the GitHub for Windows website, at http://windows.github.com.


1.6 Getting Started - First-Time Git Setup

配置工具 git config


<非Windows>

三个层次配置,配置项的位置:

系统级 git config --system /etc/gitconfig file

用户级 git config --global ~/.config/git/config

目录级 config file in the git directory

下层配置override上层配置

<Windows> (不知道哪个文件是哪个层级的了)

$Home 下的.gitconfig文件

git安装目录下的/etc/gitconfig

C:\ProgramData\Git\config --his config file can only be changed by git config -f <file> as an admin.

Your Identity

用git config --global user.name "xxxxxxx" 和 git config --global user.email "xxxxxxx" 设定全局ID

可以为具体项目单独设定id,在项目下,不用--global

Your Editor

core.editor

列出配置项

git config --list

查看单个配置项

git config 配置项名


1.7 Getting Started - Getting Help


命令1: $git help <verb>

命令2: $git <verb> --help

命令3: $man git-<verb>


 you can try the #git or #github channel on the Freenode IRC server (irc.freenode.net). (打不开)


2.1 Git Basics - Getting a Git Repository

Getting a Git Repository

Method 1: Initializing a Repository in an Existing Directory

cd 进入需要建立git repository的目录

$ git init

在此目录下会生成名为.git的一个文件夹--一个git repository框架

git add 添加要追踪的文件 

// 遇到 "LF will be replaced by CRLF " 说明相关文件是以LF结尾的。

什么是LF?什么是CRLF ?Git中的CRLF和LF  两者区别 StackOverFlow 相关问题

// 配置项 git config core.autocrlf 是True

git commit 提交


Method 2: Cloning an Existing Repository


 "clone" and not "checkout". 区别很大,前者下载了所有历史数据,后者只下了当前的工作数据。

命令: $git clone [url] (重命名库名)

2.2 Git Basics - Recording Changes to the Repository













  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值