`
leonzhx
  • 浏览: 796942 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

Chapter 1. Getting Started

阅读更多

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

 

2.  Local Version Control Systems have a simple database that kept all the changes to files under revision control while Centralized Version Control Systems have a single server that contains all the versioned files, and a number of clients that check out files from that central place.

 

3.  The most obvious downside of CVCS is the single point of failure that the centralized server represents.

 

4.  In a Distributed Version Control System (such as Git, Mercurial, Bazaar, or Darcs), clients don't just check out the latest snapshot of the files: they fully mirror the repository. Thus if any server dies, and these systems were collaborating via it, any of the client repositories can be copied back up to the server to restore it. Every checkout is really a full backup of all the data.

 

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


 
Git thinks of its data more like a set of snapshots of a mini filesystem. 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 snapshot. To be efficient, if files have not changed, Git doesn't store the file again—just a link to the previous identical file it has already stored.

 


 
6.  Most operations in Git only need local files and resources to operate—generally, no information is needed from another computer on your network. Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.

 

7.  Everything in Git is check-summed before it is stored and is then referred to by that checksum. The mechanism that Git uses for this check-summing is called a SHA-1 hash. This is a 40-character string composed of hexadecimal characters (0–9 and a-f) and calculated based on the contents of a file or directory structure in Git. Git stores everything not by file name but in the Git database addressable by the hash value of its contents.

 

 

8.  Git has three main states that your files can reside in: committed, modified, and staged. Committed means that the data is safely stored in your local database. Modified means that you have changed the file but have not committed it to your database yet. Staged means that you have marked a modified file in its current version to go into your next commit snapshot.

 

9.  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.
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.
The staging area is a simple 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 becoming standard to refer to it as the staging area.
 


 
10.  The basic Git workflow goes something like this:
  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.

 

11.  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.

 

12.  To install git from source:
  1)  Install the dependencies of Git : curl, zlib, openssl, expat, and libiconv.
        $ yum install curl-devel expat-devel gettext-devel openssl-devel zlib-devel   (on Fedora)
        $ apt-get install curl-devel expat-devel gettext-devel openssl-devel zlib-devel  (on Debian based system)

 

   2)  Grab the latest snapshot from: http://git-scm.com/download

 

  3)  Compile and install :
        $ tar -zxf git-1.6.0.5.tar.gz
        $ cd git-1.6.0.5
        $ make prefix=/usr/local all
        $ sudo make prefix=/usr/local install

 

   4)    Then you can get updates via Git itself:
        $ git clone git://git.kernel.org/pub/scm/git/git.git

 

13.  Git comes with a tool called git config that lets you get and set configuration variables that control all aspects of how Git looks and operates. These variables can be stored in three different places:
    1)  /etc/gitconfig file: Contains values for every user on the system and all their repositories. If you pass the option --system to git config, it reads and writes from this file specifically. (for windows it’s Msys root which is where you install the msysgit.)
    2)  ~/.gitconfig file: Specific to your user. You can make Git read and write to this file specifically by passing the --global option.
    3)  config file in the git directory (.git/config ) of whatever repository you're currently using: Specific to that single repository.

      4) config file in any folder you specified, you can specify the config file path by passing the –file or –f option.

 

Each level overrides values in the previous level.

 

14.  The first thing you should do when you install Git is to set your username and e-mail address which is immutably baked into the commits you pass around:
    $ git config --global user.name "Sean Zhou"
    $ git config --global user.email xiangzhou@ebay.com

 

15.  You can configure the default text editor that will be used when Git needs you to type in a message. By default, Git uses your system's default editor, which is generally Vi or Vim. If you want to use a different text editor, such as Emacs, you can do the following:
    $ git config --global core.editor emacs

 

16.  You can configure the default diff tool to use to resolve merge conflicts:
    $ git config --global merge.tool vimdiff
Git accepts kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff as valid merge tools.

 

17.  You can use the git config --list command to list all the configurations Git can find at that point. You can also check what Git thinks a specific key's value is by typing git config {key}

 

18.  There are three ways to get the manual page (manpage) help for any of the Git commands:
      $ git help <verb>
      $ git <verb> --help
      $ man git-<verb>

  • 大小: 30 KB
  • 大小: 37.1 KB
  • 大小: 39.1 KB
分享到:
评论

相关推荐

    Getting.Started.with.ResearchKit.1785

    Getting Started Chapter 2. ResearchKit Hello World Chapter 3. Building Surveys Chapter 4. ResearchKit Informed Consent Chapter 5. Active Tasks Chapter 6. Navigable and Custom Tasks Chapter 7. Backend...

    Python.Essentials.1784390348

    Getting Started Chapter 2. Simple Data Types Chapter 3. Expressions And Output Chapter 4. Variables, Assignment And Scoping Rules Chapter 5. Logic, Comparisons, And Conditions Chapter 6. More Complex...

    MATLAB for Machine Learning

    Getting Started With Matlab Machine Learning Chapter 2. Importing And Organizing Data In Matlab Chapter 3. From Data To Knowledge Discovery Chapter 4. Finding Relationships Between Variables - ...

    Internet of Things Programming with JavaScript

    Getting Started with Raspberry Pi Zero Chapter 2. Connecting Things to the Raspberry Pi Zero Chapter 3. Connecting Sensors - Measure the Real Things Chapter 4. Control-Connected Devices Chapter 5. ...

    Building.Machine.Learning.Systems.with.Python.2nd.Edition

    Getting Started with Python Machine Learning Chapter 2. Classifying with Real-world Examples Chapter 3. Clustering – Finding Related Posts Chapter 4. Topic Modeling Chapter 5. Classification – ...

    SVG.Essentials.2nd.Edition.1449374352

    Getting Started Chapter 2. Using SVG in Web Pages Chapter 3. Coordinates Chapter 4. Basic Shapes Chapter 5. Document Structure Chapter 6. Transforming the Coordinate System Chapter 7. Paths Chapter 8...

    Learning.WebRTC.1783983663

    Chapter 1. Getting Started with WebRTC Chapter 2. Getting the User's Media Chapter 3. Creating a Basic WebRTC Application Chapter 4. Creating a Signaling Server Chapter 5. Connecting Clients Together ...

    Swift.2.Cookbook.17858892

    Getting Started with Xcode and Swift Chapter 2. Standard Library and Collections Chapter 3. Using Structs and Generics Chapter 4. Design Patterns with Swift Chapter 5. Multitasking in Your App ...

    OS.X.Security.and.Privacy.Yosemite.Edition.epub

    Getting Started Chapter 2. User Accounts Chapter 3. Creating an Account Chapter 4. Parental Controls Chapter 5. Editing Accounts Chapter 6. Setting Up the Login Process Chapter 7. Logging In and Out ...

    Prentice.Hall.C++.GUI.Programming.with.Qt.4.2nd.Edition.2008.chm

    Chapter 1. Getting Started Hello Qt Making Connections Laying Out Widgets Using the Reference Documentation Chapter 2. Creating Dialogs Subclassing QDialog Signals and Slots in Depth ...

    Learning.Scala.Practical.Functional.Programming.for.the.JVM

    Getting Started With The Scalable Language Chapter 2. Working With Data: Literals, Values, Variables, and Types Chapter 3. Expressions and Conditionals Chapter 4. Functions Chapter 5. First Class ...

    Java in easy steps: Covers Java 9, 6th Edition - epub格式

    Getting started Chapter 2. Performing operations Chapter 3. Making statements Chapter 4. Directing values Chapter 5. Manipulating data Chapter 6. Creating classes Chapter 7. Importing functions ...

    Building.Android.UIs.with.Custom.Views

    Getting Started Chapter 2. Implementing Your First Custom View Chapter 3. Handling Events Chapter 4. Advanced 2D Rendering Chapter 5. Introducing 3D Custom Views Chapter 6. Animations Chapter 7. ...

Global site tag (gtag.js) - Google Analytics