Git学习

一、思想理论

  1. 是什么?
    Git是一个免费的开源的分布式版本控制系统,用以高效处理从小型到超大型的项目管理。

  2. 版本控制原理与发展历程
    (1)RCS works by keeping patch sets (that is, the differences between files) in a special format on disk;
    它的工作原理是在硬盘上保存补丁集(补丁是指文件修订前后的变化);通过应用所有的补丁,可以重新计算出各个版本的文件内容
    (2)The next major issue that people encounter is that they need to collaborate with developers on other systems. To deal with this problem, Centralized Version Control Systems (CVCSs) were developed.These systems, such as CVS, Subversion, and Perforce, have a single server that contains all the versioned files, and a number of clients that check out files from that central place。
    ———The most obvious is the single point of failure that the centralized server represents. If that server goes down for an hour, then during that hour nobody can collaborate at all or save versioned changes to anything they’re working on. If the hard disk the central database is on becomes corrupted, and proper backups haven’t been kept, you lose absolutely everything — the entire history of the project except whatever single snapshots people happen to have on their local machines.
    (3)In Distributed Version Control Systems (DVCSs) clients don’t just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history.
    —— Thus, if any server dies, and these systems were collaborating via that server, any of the client repositories can be copied back up to the server to restore it. Every clone is really a full backup of all the data.
    ——–This allows you to set up several types of workflows that aren’t possible in centralized systems, such as hierarchical models.

  3. Git基本原理
    (1)what Git is
    ——-直接记录快照,而非差异比较;
    –(I)概念上来区分,其它大部分系统以文件变更列表的方式存储信息,这类系统(CVS、Subversion、Perforce、Bazaar 等等)将它们保存的信息看作是一组基本文件和每个文件随时间逐步累积的差异。存储每个文件与初始版本的差异.。
    –(II)Git 不按照以上方式对待或保存数据。 反之,Git 更像是把数据看作是对小型文件系统的一组快照。 每次你提交更新,或在 Git 中保存项目状态时,它主要对当时的全部文件制作一个快照并保存这个快照的索引。 为了高效,如果文件没有修改,Git 不再重新存储该文件,而是只保留一个链接指向之前存储的文件。 Git 对待数据更像是一个 快照流。Storing data as snapshots of the project over time。
    ——-近乎所有操作都是本地执行:
    –Most operations in Git need only local files and resources to operate — generally no information is needed from another computer on your network.
    —意味着你离线或者没有 VPN 时,几乎可以进行任何操作。 如你在飞机或火车上想做些工作,你能愉快地提交,直到有网络连接时再上传。 如你回家后 VPN 客户端不正常,你仍能工作。
    ——–Git 保证完整性
    —-(I)Everything in Git is check-summed before it is stored and is then referred to by that checksum. This means it’s impossible to change the contents of any file or directory without Git knowing about it.
    —(II)Git stores everything in its database not by file name but by the hash value of its contents.
    ———Git 一般只添加数据(Git Generally Only Adds Data)
    —-你执行的 Git 操作,几乎只往 Git 数据库中增加数据。 很难让 Git 执行任何不可逆操作,或者让它以任何方式清除数据。
    —–This makes using Git a joy because we know we can experiment without the danger of severely screwing things up.
    ——– 三种状态(The Three States)
    —(I)Git 有三种状态,你的文件可能处于其中之一:已提交(committed)、已修改(modified)和已暂存(staged)已提交表示数据已经安全的保存在本地数据库中。 已修改表示修改了文件,但还没保存到数据库中。 已暂存表示对一个已修改文件的当前版本做了标记,使之包含在下次提交的快照中。
    This leads us to the three main sections of a Git project: the Git directory, the working tree, and the staging area.
    这里写图片描述
    Figure 6. Working tree, staging area, and Git directory

—–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.
—–工作目录是对项目的某个版本独立提取出来的内容。 这些从 Git 仓库的压缩数据库中提取出来的文件,放在磁盘上供你使用或修改
—–暂存区域是一个文件,保存了下次将提交的文件列表信息,一般在 Git 仓库目录中。 有时候也被称作`‘索引’’,不过一般说法还是叫暂存区域。
—-(II)The basic Git workflow goes something like this:
——-(a)You modify files in your working tree.
——-(b)You selectively stage just those changes you want to be part of your next commit, which adds only those changes to the staging area.
——–(c)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.
(2)the fundamentals of how it works
(3) using Git effectively

  1. 参考:
    (1)官网:https://git-scm.com/
    (2)官方书籍:Pro Git:
    https://git-scm.com/book/en/v2

二、工程实践与应用

1.
2.
3.命令
git help 下 分类的 git 命令

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值