Skip to content

Commit 25e4085

Browse files
authored
Merge branch 'master' into ortografia-readme
2 parents d58d453 + f638c1f commit 25e4085

File tree

99 files changed

+3215
-1960
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3215
-1960
lines changed

README.asc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
Bem-vindo à segunda edição do livro Pro Git.
44

5-
> If you're looking for official version, in English, see https://github.com/progit/progit2[].
5+
> Se você está procurando pela versão oficial, em Inglês, vá para o link https://github.com/progit/progit2[].
66

77
Você pode achar esse livro online em: http://git-scm.com/book
88

book-en/01-introduction/sections/about-version-control.asc

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
=== About Version Control
22

33
(((version control)))
4-
What is "version control", and why should you care?
4+
What is "`version control`", and why should you care?
55
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.
6-
For the examples in this book you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
6+
For the examples in this book, you will use software source code as the files being version controlled, though in reality you can do this with nearly any type of file on a computer.
77

88
If you are a graphic or web designer and want to keep every version of an image or layout (which you would most certainly want to), a Version Control System (VCS) is a very wise thing to use.
9-
It allows you 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.
9+
It allows you to revert selected 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.
1010
Using a VCS also generally means that if you screw things up or lose files, you can easily recover.
1111
In addition, you get all this for very little overhead.
1212

@@ -19,43 +19,42 @@ It is easy to forget which directory you're in and accidentally write to the wro
1919

2020
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.
2121

22-
.Local version control.
22+
.Local version control
2323
image::images/local.png[Local version control diagram]
2424

25-
One of the more popular VCS tools was a system called RCS, which is still distributed with many computers today.
26-
Even the popular Mac OS X operating system includes the `rcs` command when you install the Developer Tools.
27-
RCS works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.
25+
One of the most popular VCS tools was a system called RCS, which is still distributed with many computers today.
26+
https://www.gnu.org/software/rcs/[RCS] works by keeping patch sets (that is, the differences between files) in a special format on disk; it can then re-create what any file looked like at any point in time by adding up all the patches.
2827

2928
==== Centralized Version Control Systems
3029

3130
(((version control,centralized)))
3231
The next major issue that people encounter is that they need to collaborate with developers on other systems.
3332
To deal with this problem, Centralized Version Control Systems (CVCSs) were developed.
34-
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. (((CVS)))(((Subversion)))(((Perforce)))
33+
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. (((CVS)))(((Subversion)))(((Perforce)))
3534
For many years, this has been the standard for version control.
3635

37-
.Centralized version control.
36+
.Centralized version control
3837
image::images/centralized.png[Centralized version control diagram]
3938

4039
This setup offers many advantages, especially over local VCSs.
4140
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.
41+
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.
4342

4443
However, this setup also has some serious downsides.
4544
The most obvious is the single point of failure that the centralized server represents.
4645
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-
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.
46+
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.
47+
Local VCSs suffer from this same problem -- whenever you have the entire history of the project in a single place, you risk losing everything.
4948

5049
==== Distributed Version Control Systems
5150

5251
(((version control,distributed)))
5352
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.
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.
53+
In a DVCS (such as Git, Mercurial, Bazaar or Darcs), clients don't just check out the latest snapshot of the files; rather, they fully mirror the repository, including its full history.
54+
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.
5655
Every clone is really a full backup of all the data.
5756

58-
.Distributed version control.
57+
.Distributed version control
5958
image::images/distributed.png[Distributed version control diagram]
6059

6160
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.
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
=== The Command Line
22

33
There are a lot of different ways to use Git.
4-
There are the original command line tools, and there are many graphical user interfaces of varying capabilities.
4+
There are the original command-line tools, and there are many graphical user interfaces of varying capabilities.
55
For this book, we will be using Git on the command line.
6-
For one, the command line is the only place you can run *all* Git commands most of the GUIs only implement some subset of Git functionality for simplicity.
7-
If you know how to run the command line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true.
6+
For one, the command line is the only place you can run _all_ Git commands -- most of the GUIs implement only a partial subset of Git functionality for simplicity.
7+
If you know how to run the command-line version, you can probably also figure out how to run the GUI version, while the opposite is not necessarily true.
88
Also, while your choice of graphical client is a matter of personal taste, _all_ users will have the command-line tools installed and available.
99

10-
So we will expect you to know how to open Terminal in Mac or Command Prompt or Powershell in Windows.
10+
So we will expect you to know how to open Terminal in macOS or Command Prompt or PowerShell in Windows.
1111
If you don't know what we're talking about here, you may need to stop and research that quickly so that you can follow the rest of the examples and descriptions in this book.

book-en/01-introduction/sections/first-time-setup.asc

Lines changed: 52 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,20 +8,30 @@ You can also change them at any time by running through the commands again.
88
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)))
99
These variables can be stored in three different places:
1010

11-
1. `/etc/gitconfig` file: Contains values for every user on the system and all their repositories.
11+
1. `[path]/etc/gitconfig` file: Contains values applied to every user on the system and all their repositories.
1212
If you pass the option `--system` to `git config`, it reads and writes from this file specifically.
13-
2. `~/.gitconfig` or `~/.config/git/config` file: Specific to your user.
14-
You can make Git read and write to this file specifically by passing the `--global` option.
13+
Because this is a system configuration file, you would need administrative or superuser privilege to make changes to it.
14+
2. `~/.gitconfig` or `~/.config/git/config` file: Values specific personally to you, the user.
15+
You can make Git read and write to this file specifically by passing the `--global` option, and this affects _all_ of the repositories you work with on your system.
1516
3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you're currently using: Specific to that single repository.
17+
You can force Git to read from and write to this file with the `--local` option, but that is in fact the default.
18+
Unsurprisingly, you need to be located somewhere in a Git repository for this option to work properly.
1619

17-
Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`.
20+
Each level overrides values in the previous level, so values in `.git/config` trump those in `[path]/etc/gitconfig`.
1821

1922
On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people).
20-
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.
23+
It also still looks for `[path]/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.
2124
If you are using version 2.x or later of Git for Windows, there is also a system-level config file at
2225
`C:\Documents and Settings\All Users\Application Data\Git\config` on Windows XP, and in `C:\ProgramData\Git\config` on Windows Vista and newer.
2326
This config file can only be changed by `git config -f <file>` as an admin.
2427

28+
You can view all of your settings and where they are coming from using:
29+
30+
[source,console]
31+
----
32+
$ git config --list --show-origin
33+
----
34+
2535
==== Your Identity
2636

2737
The first thing you should do when you install Git is to set your user name and email address.
@@ -38,6 +48,7 @@ If you want to override this with a different name or email address for specific
3848

3949
Many of the GUI tools will help you do this when you first run them.
4050

51+
[[_editor]]
4152
==== Your Editor
4253

4354
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.
@@ -50,34 +61,44 @@ If you want to use a different text editor, such as Emacs, you can do the follow
5061
$ git config --global core.editor emacs
5162
----
5263

53-
While on a Windows system, if you want to use a different text editor, such as Notepad++, you can do the following:
64+
On a Windows system, if you want to use a different text editor, you must specify the full path to its executable file.
65+
This can be different depending on how your editor is packaged.
66+
67+
In the case of Notepad++, a popular programming editor, you are likely to want to use the 32-bit version, since at the time of writing the 64-bit version doesn't support all plug-ins.
68+
If you are on a 32-bit Windows system, or you have a 64-bit editor on a 64-bit system, you'll type something like this:
5469

55-
On a x86 system
56-
[source,console]
57-
----
58-
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -nosession"
59-
----
60-
On a x64 system
6170
[source,console]
6271
----
63-
$ git config --global core.editor "'C:/Program Files (x86)/Notepad++/notepad++.exe' -multiInst -nosession"
72+
$ git config --global core.editor "'C:/Program Files/Notepad++/notepad++.exe' -multiInst -notabbar -nosession -noPlugin"
6473
----
6574

6675
[NOTE]
6776
====
68-
Vim, Emacs and Notepad++ are popular text editors often used by developers on Unix based systems like Linux and OS X or a Windows system.
69-
If you are not familiar with either of these editors, you may need to search for specific instructions for how to set up your favorite editor with Git.
77+
Vim, Emacs and Notepad++ are popular text editors often used by developers on Unix-based systems like Linux and macOS or a Windows system.
78+
If you are using another editor, or a 32-bit version, please find specific instructions for how to set up your favorite editor with Git in <<C-git-commands#ch_core_editor>>.
7079
====
7180

7281
[WARNING]
7382
====
74-
You may find, if you don't setup an editor like this, you will likely get into a really confusing state when they are launched.
75-
Such example on a Windows system may include a prematurely terminated Git operation during a Git initiated edit.
83+
You may find, if you don't setup your editor like this, you get into a really confusing state when Git attempts to launch it.
84+
An example on a Windows system may include a prematurely terminated Git operation during a Git initiated edit.
7685
====
7786

87+
==== Your default branch name
88+
89+
By default Git will create a branch called _master_ when you create a new repository with `git init`.
90+
From Git version 2.28 onwards, you can set a different name for the initial branch.
91+
92+
To set _main_ as the default branch name do:
93+
94+
[source,console]
95+
----
96+
$ git config --global init.defaultBranch main
97+
----
98+
7899
==== Checking Your Settings
79100

80-
If you want to check your settings, you can use the `git config --list` command to list all the settings Git can find at that point:
101+
If you want to check your configuration settings, you can use the `git config --list` command to list all the settings Git can find at that point:
81102

82103
[source,console]
83104
----
@@ -91,7 +112,7 @@ color.diff=auto
91112
...
92113
----
93114

94-
You may see keys more than once, because Git reads the same key from different files (`/etc/gitconfig` and `~/.gitconfig`, for example).
115+
You may see keys more than once, because Git reads the same key from different files (`[path]/etc/gitconfig` and `~/.gitconfig`, for example).
95116
In this case, Git uses the last value for each unique key it sees.
96117

97118
You can also check what Git thinks a specific key's value is by typing `git config <key>`:(((git commands, config)))
@@ -101,3 +122,15 @@ You can also check what Git thinks a specific key's value is by typing `git conf
101122
$ git config user.name
102123
John Doe
103124
----
125+
126+
[NOTE]
127+
====
128+
Since Git might read the same configuration variable value from more than one file, it's possible that you have an unexpected value for one of these values and you don't know why.
129+
In cases like that, you can query Git as to the _origin_ for that value, and it will tell you which configuration file had the final say in setting that value:
130+
131+
[source,console]
132+
----
133+
$ git config --show-origin rerere.autoUpdate
134+
file:/home/johndoe/.gitconfig false
135+
----
136+
====
Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[[_git_help]]
22
=== Getting Help
33

4-
If you ever need help while using Git, there are three ways to get the manual page (manpage) help for any of the Git commands:
4+
If you ever need help while using Git, there are three equivalent ways to get the comprehensive manual page (manpage) help for any of the Git commands:
55

66
[source,console]
77
----
@@ -10,13 +10,39 @@ $ git <verb> --help
1010
$ man git-<verb>
1111
----
1212

13-
For example, you can get the manpage help for the config command by running(((git commands, help)))
13+
For example, you can get the manpage help for the `git config` command by running this:(((git commands, help)))
1414

1515
[source,console]
1616
----
1717
$ git help config
1818
----
1919

2020
These commands are nice because you can access them anywhere, even offline.
21-
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).
21+
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, which can be found at https://freenode.net[].
2222
These channels are regularly filled with hundreds of people who are all very knowledgeable about Git and are often willing to help.(((IRC)))
23+
24+
In addition, if you don't need the full-blown manpage help, but just need a quick refresher on the available options for a Git command, you can ask for the more concise "`help`" output with the `-h` option, as in:
25+
26+
[source,console]
27+
----
28+
$ git add -h
29+
usage: git add [<options>] [--] <pathspec>...
30+
31+
-n, --dry-run dry run
32+
-v, --verbose be verbose
33+
34+
-i, --interactive interactive picking
35+
-p, --patch select hunks interactively
36+
-e, --edit edit current diff and apply
37+
-f, --force allow adding otherwise ignored files
38+
-u, --update update tracked files
39+
--renormalize renormalize EOL of tracked files (implies -u)
40+
-N, --intent-to-add record only the fact that the path will be added later
41+
-A, --all add changes from all tracked and untracked files
42+
--ignore-removal ignore paths removed in the working tree (same as --no-all)
43+
--refresh don't add, only refresh the index
44+
--ignore-errors just skip files which cannot be added because of errors
45+
--ignore-missing check if - even missing - files are ignored in dry run
46+
--chmod (+|-)x override the executable bit of the listed files
47+
----
48+

book-en/01-introduction/sections/history.asc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,4 @@ Some of the goals of the new system were as follows:
1717
* Able to handle large projects like the Linux kernel efficiently (speed and data size)
1818
1919
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 amazingly fast, it's very efficient with large projects, and it has an incredible branching system for non-linear development (See <<ch03-git-branching#ch03-git-branching>>).

0 commit comments

Comments
 (0)