|
| 1 | +[[_getting_started]] |
1 | 2 | == Getting Started
|
2 | 3 |
|
3 | 4 | This chapter will be about getting started with Git.
|
@@ -34,7 +35,7 @@ RCS works by keeping patch sets (that is, the differences between files) in a sp
|
34 | 35 |
|
35 | 36 | The next major issue that people encounter is that they need to collaborate with developers on other systems.
|
36 | 37 | To deal with this problem, Centralized Version Control Systems (CVCSs) were developed.
|
37 |
| -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))) |
| 38 | +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))) |
38 | 39 | For many years, this has been the standard for version control.
|
39 | 40 |
|
40 | 41 | .Centralized version control.
|
@@ -211,11 +212,11 @@ You can either install it as a package or via another installer, or download the
|
211 | 212 | ==== Installing on Linux(((Linux, installing)))
|
212 | 213 |
|
213 | 214 | 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.
|
214 |
| -If you’re on Fedora, you can use yum: |
| 215 | +If you’re on Fedora for example, you can use yum: |
215 | 216 |
|
216 | 217 | $ yum install git
|
217 | 218 |
|
218 |
| -Or if you’re on a Debian-based distribution like Ubuntu, try apt-get: |
| 219 | +If you’re on a Debian-based distribution like Ubuntu, try apt-get: |
219 | 220 |
|
220 | 221 | $ apt-get install git
|
221 | 222 |
|
@@ -245,32 +246,11 @@ The most official build is available for download on the Git website.
|
245 | 246 | Just go to http://git-scm.com/download/win[] and the download will start automatically.
|
246 | 247 | Note that this is a project called Git for Windows (also called msysGit), which is separate from Git itself; for more information on it, go to http://msysgit.github.io/[].
|
247 | 248 |
|
248 |
| - |
249 | 249 | Another easy way to get Git installed is by installing GitHub for Windows.
|
250 | 250 | The installer includes a command line version of Git as well as the GUI.
|
251 | 251 | It also works well with Powershell, and sets up solid credential caching and sane CRLF settings.
|
252 | 252 | We'll learn more about those things a little later, but suffice it to say they're things you want.
|
253 | 253 |
|
254 |
| -=== First-Time Git Setup |
255 |
| - |
256 |
| -Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. |
257 |
| -You should have to do these things only once on any given computer; they’ll stick around between upgrades. |
258 |
| -You can also change them at any time by running through the commands again. |
259 |
| - |
260 |
| -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, config))) |
261 |
| -These variables can be stored in three different places: |
262 |
| - |
263 |
| -1. `/etc/gitconfig` file: Contains values for every user on the system and all their repositories. |
264 |
| - If you pass the option` --system` to `git config`, it reads and writes from this file specifically. |
265 |
| -2. `~/.gitconfig` or `~/.config/git/config` file: Specific to your user. |
266 |
| - You can make Git read and write to this file specifically by passing the `--global` option. |
267 |
| -3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you’re currently using: Specific to that single repository. |
268 |
| - |
269 |
| -Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`. |
270 |
| - |
271 |
| -On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people). |
272 |
| -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. |
273 |
| - |
274 | 254 | ==== Installing from Source
|
275 | 255 |
|
276 | 256 | Some people may instead find it useful to install Git from source, because you’ll get the most recent version.
|
@@ -302,27 +282,53 @@ After this is done, you can also get Git via Git itself for updates:
|
302 | 282 |
|
303 | 283 | $ git clone git://git.kernel.org/pub/scm/git/git.git
|
304 | 284 |
|
| 285 | + |
| 286 | +=== First-Time Git Setup |
| 287 | + |
| 288 | +Now that you have Git on your system, you’ll want to do a few things to customize your Git environment. |
| 289 | +You should have to do these things only once on any given computer; they’ll stick around between upgrades. |
| 290 | +You can also change them at any time by running through the commands again. |
| 291 | + |
| 292 | +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, config))) |
| 293 | +These variables can be stored in three different places: |
| 294 | + |
| 295 | +1. `/etc/gitconfig` file: Contains values for every user on the system and all their repositories. |
| 296 | + If you pass the option` --system` to `git config`, it reads and writes from this file specifically. |
| 297 | +2. `~/.gitconfig` or `~/.config/git/config` file: Specific to your user. |
| 298 | + You can make Git read and write to this file specifically by passing the `--global` option. |
| 299 | +3. `config` file in the Git directory (that is, `.git/config`) of whatever repository you’re currently using: Specific to that single repository. |
| 300 | + |
| 301 | +Each level overrides values in the previous level, so values in `.git/config` trump those in `/etc/gitconfig`. |
| 302 | + |
| 303 | +On Windows systems, Git looks for the `.gitconfig` file in the `$HOME` directory (`C:\Users\$USER` for most people). |
| 304 | +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. |
| 305 | + |
305 | 306 | ==== Your Identity
|
306 | 307 |
|
307 | 308 | The first thing you should do when you install Git is to set your user name and e-mail address.
|
308 |
| -This is important because every Git commit uses this information, and it’s immutably baked into the commits you pass around: |
| 309 | +This is important because every Git commit uses this information, and it’s immutably baked into the commits you start creating: |
309 | 310 |
|
310 | 311 | $ git config --global user.name "John Doe"
|
311 | 312 | $ git config --global user.email [email protected]
|
312 | 313 |
|
313 | 314 | 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.
|
314 | 315 | 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.
|
315 | 316 |
|
316 |
| -Many of the GUI tools will help you do this when you first run them as well. |
| 317 | +Many of the GUI tools will help you do this when you first run them. |
317 | 318 |
|
318 | 319 | ==== Your Editor
|
319 | 320 |
|
320 | 321 | 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.
|
321 |
| -By default, Git uses your system’s default editor, which is generally vi or Vim. |
| 322 | +If not configured, Git uses your system’s default editor, which is generally Vim. |
322 | 323 | If you want to use a different text editor, such as Emacs, you can do the following:
|
323 | 324 |
|
324 | 325 | $ git config --global core.editor emacs
|
325 | 326 |
|
| 327 | +[NOTE] |
| 328 | +==== |
| 329 | +Vim and Emacs are popular text editors often used by developers on Unix based systems like Linux and Mac. If you are not familiar with either of these editors or are on a Windows system, you may need to search for instructions for how to set up your favorite editor with Git. |
| 330 | +==== |
| 331 | + |
326 | 332 | ==== Checking Your Settings
|
327 | 333 |
|
328 | 334 | 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:
|
@@ -362,6 +368,6 @@ These channels are regularly filled with hundreds of people who are all very kno
|
362 | 368 |
|
363 | 369 | === Summary
|
364 | 370 |
|
365 |
| -You should have a basic understanding of what Git is and how it’s different from the CVCS you may have been using. |
| 371 | +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. |
366 | 372 | You should also now have a working version of Git on your system that’s set up with your personal identity.
|
367 | 373 | It’s now time to learn some Git basics.
|
0 commit comments