epubjs
Version:
Render ePub documents in the browser, across many devices
72 lines (50 loc) • 5.22 kB
HTML
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Pro Git - professional version control</title>
<meta content="http://www.w3.org/1999/xhtml; charset=utf-8" http-equiv="Content-Type"/>
<link href="stylesheet.css" type="text/css" rel="stylesheet"/>
<style type="text/css">
@page { margin-bottom: 5.000000pt; margin-top: 5.000000pt; }</style>
</head>
<body class="calibre">
<h2 class="calibre4" id="calibre_pb_6">First-Time Git Setup</h2>
<p class="calibre3">Now that you have Git on your system, you'll want to do a few things to customize your Git environment. You should have to do these things only once; they'll stick around between upgrades. You can also change them at any time by running through the commands again.</p>
<p class="calibre3">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:</p>
<ul class="calibre7"><li class="calibre8"><code class="calibre10">/etc/gitconfig</code> file: Contains values for every user on the system and all their repositories. If you pass the option<code class="calibre10">--system</code> to <code class="calibre10">git config</code>, it reads and writes from this file specifically. </li>
<li class="calibre8"><code class="calibre10">~/.gitconfig</code> file: Specific to your user. You can make Git read and write to this file specifically by passing the <code class="calibre10">--global</code> option. </li>
<li class="calibre8">config file in the git directory (that is, <code class="calibre10">.git/config</code>) of whatever repository you're currently using: Specific to that single repository. Each level overrides values in the previous level, so values in <code class="calibre10">.git/config</code> trump those in <code class="calibre10">/etc/gitconfig</code>.</li>
</ul><p class="calibre3">On Windows systems, Git looks for the <code class="calibre10">.gitconfig</code> file in the <code class="calibre10">$HOME</code> directory (<code class="calibre10">C:\Documents and Settings\$USER</code> for most people). 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.</p>
<h3 class="calibre5">Your Identity</h3>
<p class="calibre3">The first thing you should do when you install Git is to set your user name and e-mail address. This is important because every Git commit uses this information, and it's immutably baked into the commits you pass around:</p>
<pre class="calibre9"><code class="calibre10">$ git config --global user.name "John Doe"
$ git config --global user.email johndoe@example.com
</code></pre>
<p class="calibre3">Again, you need to do this only once if you pass the <code class="calibre10">--global</code> option, because then Git will always use that information for anything you do on that system. If you want to override this with a different name or e-mail address for specific projects, you can run the command without the <code class="calibre10">--global</code> option when you're in that project.</p>
<h3 class="calibre5">Your Editor</h3>
<p class="calibre3">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. 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:</p>
<pre class="calibre9"><code class="calibre10">$ git config --global core.editor emacs
</code></pre>
<h3 class="calibre5">Your Diff Tool</h3>
<p class="calibre3">Another useful option you may want to configure is the default diff tool to use to resolve merge conflicts. Say you want to use vimdiff:</p>
<pre class="calibre9"><code class="calibre10">$ git config --global merge.tool vimdiff
</code></pre>
<p class="calibre3">Git accepts kdiff3, tkdiff, meld, xxdiff, emerge, vimdiff, gvimdiff, ecmerge, and opendiff as valid merge tools. You can also set up a custom tool; see Chapter 7 for more information about doing that.</p>
<h3 class="calibre5">Checking Your Settings</h3>
<p class="calibre3">If you want to check your settings, you can use the <code class="calibre10">git config --list</code> command to list all the settings Git can find at that point:</p>
<pre class="calibre9"><code class="calibre10">$ git config --list
user.name=Scott Chacon
user.email=schacon@gmail.com
color.status=auto
color.branch=auto
color.interactive=auto
color.diff=auto
...
</code></pre>
<p class="calibre3">You may see keys more than once, because Git reads the same key from different files (<code class="calibre10">/etc/gitconfig</code> and <code class="calibre10">~/.gitconfig</code>, for example). In this case, Git uses the last value for each unique key it sees.</p>
<p class="calibre3">You can also check what Git thinks a specific key's value is by typing <code class="calibre10">git config {key}</code>:</p>
<pre class="calibre9"><code class="calibre10">$ git config user.name
Scott Chacon
</code></pre>
</body>
</html>