You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: book/01-introduction/1-introduction.asc
+3-3
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,6 @@ include::sections/help.asc[]
21
21
22
22
=== Summary
23
23
24
-
You should have a basic understanding of what Git is and how it’s different from the centralized version control system you may have previously been using.
25
-
You should also now have a working version of Git on your system that’s set up with your personal identity.
26
-
It’s now time to learn some Git basics.
24
+
You should have a basic understanding of what Git is and how it's different from the centralized version control system you may have previously been using.
25
+
You should also now have a working version of Git on your system that's set up with your personal identity.
Copy file name to clipboardexpand all lines: book/01-introduction/sections/about-version-control.asc
+7-7
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ In addition, you get all this for very little overhead.
13
13
==== Local Version Control Systems
14
14
15
15
(((version control,local)))
16
-
Many people’s version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they’re clever).
16
+
Many people's version-control method of choice is to copy files into another directory (perhaps a time-stamped directory, if they're clever).
17
17
This approach is very common because it is so simple, but it is also incredibly error prone.
18
-
It is easy to forget which directory you’re in and accidentally write to the wrong file or copy over files you don’t mean to.
18
+
It is easy to forget which directory you're in and accidentally write to the wrong file or copy over files you don't mean to.
19
19
20
20
To deal with this issue, programmers long ago developed local VCSs that had a simple database that kept all the changes to files under revision control.
21
21
@@ -39,24 +39,24 @@ image::images/centralized.png[Centralized version control diagram]
39
39
40
40
This setup offers many advantages, especially over local VCSs.
41
41
For example, everyone knows to a certain degree what everyone else on the project is doing.
42
-
Administrators have fine-grained control over who can do what; and it’s far easier to administer a CVCS than it is to deal with local databases on every client.
42
+
Administrators have fine-grained control over who can do what; and it's far easier to administer a CVCS than it is to deal with local databases on every client.
43
43
44
44
However, this setup also has some serious downsides.
45
45
The most obvious is the single point of failure that the centralized server represents.
46
-
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.
47
-
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.
46
+
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.
47
+
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.
48
48
Local VCS systems suffer from this same problem – whenever you have the entire history of the project in a single place, you risk losing everything.
49
49
50
50
==== Distributed Version Control Systems
51
51
52
52
(((version control,distributed)))
53
53
This is where Distributed Version Control Systems (DVCSs) step in.
54
-
In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don’t just check out the latest snapshot of the files: they fully mirror the repository.
54
+
In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don't just check out the latest snapshot of the files: they fully mirror the repository.
55
55
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.
56
56
Every checkout is really a full backup of all the data.
57
57
58
58
.Distributed version control.
59
59
image::images/distributed.png[Distributed version control diagram]
60
60
61
61
Furthermore, many of these systems deal pretty well with having several remote repositories they can work with, so you can collaborate with different groups of people in different ways simultaneously within the same project.
62
-
This allows you to set up several types of workflows that aren’t possible in centralized systems, such as hierarchical models.
62
+
This allows you to set up several types of workflows that aren't possible in centralized systems, such as hierarchical models.
Copy file name to clipboardexpand all lines: book/01-introduction/sections/basics.asc
+16-16
Original file line number
Diff line number
Diff line change
@@ -14,10 +14,10 @@ These systems (CVS, Subversion, Perforce, Bazaar, and so on) think of the inform
14
14
.Storing data as changes to a base version of each file.
15
15
image::images/deltas.png[Storing data as changes to a base version of each file.]
16
16
17
-
Git doesn’t think of or store its data this way.
17
+
Git doesn't think of or store its data this way.
18
18
Instead, Git thinks of its data more like a set of snapshots of a miniature filesystem.
19
19
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.
20
-
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.
20
+
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.
21
21
Git thinks about its data more like a *stream of snapshots*.
22
22
23
23
.Storing data as snapshots of the project over time.
@@ -26,31 +26,31 @@ image::images/snapshots.png[Git stores data as snapshots of the project over tim
26
26
This is an important distinction between Git and nearly all other VCSs.
27
27
It makes Git reconsider almost every aspect of version control that most other systems copied from the previous generation.
28
28
This makes Git more like a mini filesystem with some incredibly powerful tools built on top of it, rather than simply a VCS.
29
-
We’ll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <<_git_branching>>.
29
+
We'll explore some of the benefits you gain by thinking of your data this way when we cover Git branching in <<_git_branching>>.
30
30
31
31
==== Nearly Every Operation Is Local
32
32
33
33
Most operations in Git only need local files and resources to operate – generally no information is needed from another computer on your network.
34
-
If you’re used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers.
34
+
If you're used to a CVCS where most operations have that network latency overhead, this aspect of Git will make you think that the gods of speed have blessed Git with unworldly powers.
35
35
Because you have the entire history of the project right there on your local disk, most operations seem almost instantaneous.
36
36
37
-
For example, to browse the history of the project, Git doesn’t need to go out to the server to get the history and display it for you – it simply reads it directly from your local database.
37
+
For example, to browse the history of the project, Git doesn't need to go out to the server to get the history and display it for you – it simply reads it directly from your local database.
38
38
This means you see the project history almost instantly.
39
39
If you want to see the changes introduced between the current version of a file and the file a month ago, Git can look up the file a month ago and do a local difference calculation, instead of having to either ask a remote server to do it or pull an older version of the file from the remote server to do it locally.
40
40
41
-
This also means that there is very little you can’t do if you’re offline or off VPN.
41
+
This also means that there is very little you can't do if you're offline or off VPN.
42
42
If you get on an airplane or a train and want to do a little work, you can commit happily until you get to a network connection to upload.
43
-
If you go home and can’t get your VPN client working properly, you can still work.
43
+
If you go home and can't get your VPN client working properly, you can still work.
44
44
In many other systems, doing so is either impossible or painful.
45
-
In Perforce, for example, you can’t do much when you aren’t connected to the server; and in Subversion and CVS, you can edit files, but you can’t commit changes to your database (because your database is offline).
45
+
In Perforce, for example, you can't do much when you aren't connected to the server; and in Subversion and CVS, you can edit files, but you can't commit changes to your database (because your database is offline).
46
46
This may not seem like a huge deal, but you may be surprised what a big difference it can make.
47
47
48
48
==== Git Has Integrity
49
49
50
50
Everything in Git is check-summed before it is stored and is then referred to by that checksum.
51
-
This means it’s impossible to change the contents of any file or directory without Git knowing about it.
51
+
This means it's impossible to change the contents of any file or directory without Git knowing about it.
52
52
This functionality is built into Git at the lowest levels and is integral to its philosophy.
53
-
You can’t lose information in transit or get file corruption without Git being able to detect it.
53
+
You can't lose information in transit or get file corruption without Git being able to detect it.
54
54
55
55
The mechanism that Git uses for this checksumming is called a SHA-1 hash.(((SHA-1)))
56
56
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.
@@ -65,10 +65,10 @@ In fact, Git stores everything in its database not by file name but by the hash
65
65
66
66
When you do actions in Git, nearly all of them only add data to the Git database.
67
67
It is hard to get the system to do anything that is not undoable or to make it erase data in any way.
68
-
As in any VCS, you can lose or mess up changes you haven’t committed yet; but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.
68
+
As in any VCS, you can lose or mess up changes you haven't committed yet; but after you commit a snapshot into Git, it is very difficult to lose, especially if you regularly push your database to another repository.
69
69
70
70
This makes using Git a joy because we know we can experiment without the danger of severely screwing things up.
71
-
For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<_git_objects>>.
71
+
For a more in-depth look at how Git stores its data and how you can recover data that seems lost, see <<_undoing>>.
72
72
73
73
==== The Three States
74
74
@@ -91,15 +91,15 @@ The working directory is a single checkout of one version of the project.
91
91
These files are pulled out of the compressed database in the Git directory and placed on disk for you to use or modify.
92
92
93
93
The staging area is a file, generally contained in your Git directory, that stores information about what will go into your next commit.
94
-
It’s sometimes referred to as the ``index'', but it’s also common to refer to it as the staging area.
94
+
It's sometimes referred to as the ``index'', but it's also common to refer to it as the staging area.
95
95
96
96
The basic Git workflow goes something like this:
97
97
98
98
1. You modify files in your working directory.
99
99
2. You stage the files, adding snapshots of them to your staging area.
100
100
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.
101
101
102
-
If a particular version of a file is in the Git directory, it’s considered committed.
103
-
If it’s modified but has been added to the staging area, it is staged.
102
+
If a particular version of a file is in the Git directory, it's considered committed.
103
+
If it's modified but has been added to the staging area, it is staged.
104
104
And if it was changed since it was checked out but has not been staged, it is modified.
105
-
In <<_git_basics_chapter>>, you’ll learn more about these states and how you can either take advantage of them or skip the staged part entirely.
105
+
In <<_git_basics_chapter>>, you'll learn more about these states and how you can either take advantage of them or skip the staged part entirely.
Copy file name to clipboardexpand all lines: book/01-introduction/sections/first-time-setup.asc
+8-8
Original file line number
Diff line number
Diff line change
@@ -1,7 +1,7 @@
1
1
=== First-Time Git Setup
2
2
3
-
Now that you have Git on your system, you’ll want to do a few things to customize your Git environment.
4
-
You should have to do these things only once on any given computer; they’ll stick around between upgrades.
3
+
Now that you have Git on your system, you'll want to do a few things to customize your Git environment.
4
+
You should have to do these things only once on any given computer; they'll stick around between upgrades.
5
5
You can also change them at any time by running through the commands again.
6
6
7
7
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.(((git commands, config)))
@@ -11,30 +11,30 @@ These variables can be stored in three different places:
11
11
If you pass the option `--system` to `git config`, it reads and writes from this file specifically.
12
12
2. `~/.gitconfig` or `~/.config/git/config` file: Specific to your user.
13
13
You can make Git read and write to this file specifically by passing the `--global` option.
14
-
3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you’re currently using: Specific to that single repository.
14
+
3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you're currently using: Specific to that single repository.
15
15
16
16
Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`.
17
17
18
18
On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people).
19
-
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.
19
+
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.
20
20
21
21
==== Your Identity
22
22
23
23
The first thing you should do when you install Git is to set your user name and e-mail address.
24
-
This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating:
24
+
This is important because every Git commit uses this information, and it's immutably baked into the commits you start creating:
Again, you need to do this only once if you pass the `--global` option, because then Git will always use that information for anything you do on that system.
30
-
If you want to override this with a different name or e-mail address for specific projects, you can run the command without the `--global` option when you’re in that project.
30
+
If you want to override this with a different name or e-mail address for specific projects, you can run the command without the `--global` option when you're in that project.
31
31
32
32
Many of the GUI tools will help you do this when you first run them.
33
33
34
34
==== Your Editor
35
35
36
36
Now that your identity is set up, you can configure the default text editor that will be used when Git needs you to type in a message.
37
-
If not configured, Git uses your system’s default editor, which is generally Vim.
37
+
If not configured, Git uses your system's default editor, which is generally Vim.
38
38
If you want to use a different text editor, such as Emacs, you can do the following:
39
39
40
40
$ git config --global core.editor emacs
@@ -60,7 +60,7 @@ If you want to check your settings, you can use the `git config --list` command
60
60
You may see keys more than once, because Git reads the same key from different files (`/etc/gitconfig` and `~/.gitconfig`, for example).
61
61
In this case, Git uses the last value for each unique key it sees.
62
62
63
-
You can also check what Git thinks a specific key’s value is by typing `git config <key>`:(((git commands, config)))
63
+
You can also check what Git thinks a specific key's value is by typing `git config <key>`:(((git commands, config)))
Copy file name to clipboardexpand all lines: book/01-introduction/sections/help.asc
+1-1
Original file line number
Diff line number
Diff line change
@@ -12,5 +12,5 @@ For example, you can get the manpage help for the config command by running(((gi
12
12
$ git help config
13
13
14
14
These commands are nice because you can access them anywhere, even offline.
15
-
If the manpages and this book aren’t enough and you need in-person help, you can try the `#git` or `#github` channel on the Freenode IRC server (irc.freenode.net).
15
+
If the manpages and this book aren't enough and you need in-person help, you can try the `#git` or `#github` channel on the Freenode IRC server (irc.freenode.net).
16
16
These channels are regularly filled with hundreds of people who are all very knowledgeable about Git and are often willing to help.(((IRC)))
Copy file name to clipboardexpand all lines: book/01-introduction/sections/history.asc
+2-2
Original file line number
Diff line number
Diff line change
@@ -6,7 +6,7 @@ The Linux kernel is an open source software project of fairly large scope.(((Lin
6
6
For most of the lifetime of the Linux kernel maintenance (1991–2002), changes to the software were passed around as patches and archived files.
7
7
In 2002, the Linux kernel project began using a proprietary DVCS called BitKeeper.(((BitKeeper)))
8
8
9
-
In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool’s free-of-charge status was revoked.
9
+
In 2005, the relationship between the community that developed the Linux kernel and the commercial company that developed BitKeeper broke down, and the tool's free-of-charge status was revoked.
10
10
This prompted the Linux development community (and in particular Linus Torvalds, the creator of Linux) to develop their own tool based on some of the lessons they learned while using BitKeeper.(((Linus Torvalds)))
11
11
Some of the goals of the new system were as follows:
12
12
@@ -17,4 +17,4 @@ Some of the goals of the new system were as follows:
17
17
* Able to handle large projects like the Linux kernel efficiently (speed and data size)
18
18
19
19
Since its birth in 2005, Git has evolved and matured to be easy to use and yet retain these initial qualities.
20
-
It’s incredibly fast, it’s very efficient with large projects, and it has an incredible branching system for non-linear development (See <<_git_branching>>).
20
+
It's incredibly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (See <<_git_branching>>).
Copy file name to clipboardexpand all lines: book/01-introduction/sections/installing.asc
+4-4
Original file line number
Diff line number
Diff line change
@@ -13,11 +13,11 @@ This book was written using Git version *2.0.0*. Though most of the commands we
13
13
14
14
(((Linux, installing)))
15
15
If you want to install Git on Linux via a binary installer, you can generally do so through the basic package-management tool that comes with your distribution.
16
-
If you’re on Fedora for example, you can use yum:
16
+
If you're on Fedora for example, you can use yum:
17
17
18
18
$ yum install git
19
19
20
-
If you’re on a Debian-based distribution like Ubuntu, try apt-get:
20
+
If you're on a Debian-based distribution like Ubuntu, try apt-get:
21
21
22
22
$ apt-get install git
23
23
@@ -57,11 +57,11 @@ You can download this from the GitHub for Windows website, at http://windows.git
57
57
58
58
==== Installing from Source
59
59
60
-
Some people may instead find it useful to install Git from source, because you’ll get the most recent version.
60
+
Some people may instead find it useful to install Git from source, because you'll get the most recent version.
61
61
The binary installers tend to be a bit behind, though as Git has matured in recent years, this has made less of a difference.
62
62
63
63
If you do want to install Git from source, you need to have the following libraries that Git depends on: curl, zlib, openssl, expat, and libiconv.
64
-
For example, if you’re on a system that has yum (such as Fedora) or apt-get (such as a Debian based system), you can use one of these commands to install all of the dependencies:
64
+
For example, if you're on a system that has yum (such as Fedora) or apt-get (such as a Debian based system), you can use one of these commands to install all of the dependencies:
0 commit comments