This repository has been archived by the owner on Mar 14, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 77
/
setup.html
140 lines (105 loc) · 7.04 KB
/
setup.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Learn.GitHub - Setup and Initialization</title>
<script type="text/javascript" src="../js/jquery-1.2.6.pack.js"></script>
<script type="text/javascript" src="../js/thickbox-compressed.js"></script>
<script type="text/javascript" src="../js/jquery.corner.js"></script>
<link rel="stylesheet" href="../css/screen.css" type="text/css" media="screen, projection">
<link rel="stylesheet" href="../css/print.css" type="text/css" media="print">
<!--[if IE]>
<link rel="stylesheet" href="../css/ie.css" type="text/css" media="screen, projection">
<![endif]-->
<link rel="stylesheet" href="../css/style.css" type="text/css" media="screen" charset="utf-8"/>
<link rel="stylesheet" href="../css/thickbox.css" type="text/css" media="screen"/>
</head>
<body>
<div class="container">
<div class="span-21" id="header">
<div class="span-10">
<a href="/"><img src="../images/learn.github.png" alt="github learn logo" /></a>
</div>
<div class="span-11 last">
<div id="links">
<a href="http://github.com">home</a>
<a href="http://github.com/login">login</a>
<a href="http://github.com/signup">signup!</a>
</div>
</div>
</div>
<div class="span-21" id="welcome">
<h1>Setup and Initialization</h1>
<p>Setup your Git environment, then create a new Git repository and clone an existing one.</p>
</div>
<div class="content">
<div class="span-21"><center><embed src="http://blip.tv/play/AeyWYQAI" type="application/x-shockwave-flash" width="790" height="444" allowscriptaccess="always" allowfullscreen="true"></embed></center><hr/><h3 id='setting_up_git'>setting up git</h3>
<p>When you first start using Git, there are a few things you will likely want to get setup before you start. Git records your name and email address when you create commits, so you need to tell Git what those are. You can use the <code>git config</code> command to set those. If you pass <code>--global</code>, it will save the values in the ‘~/.gitconfig’ file so they are the default for all of your repositories.</p>
<pre><code>$ git config --global user.name "Scott Chacon"
$ git config --global user.email "schacon@gmail.com"</code></pre>
<p>Git also uses a text editor for creating commit messages and a few other things that by default will use the vim text editor. If you prefer something else, like emacs for example, you’ll have to set that, too.</p>
<pre><code>$ git config --global core.editor 'emacs'</code></pre>
<p>To check your configuration values, you can just run something like this:</p>
<pre><code>$ git config user.name</code></pre>
<p>Or you can edit the files yourself. Git will first check ‘/etc/gitconfig’, then ‘~/.gitconfig’, and finally ‘.git/config’ for these values. The format looks like this:</p>
<pre><code>$ cat ~/.gitconfig
[user]
name = Scott Chacon
email = schacon@gmail.com</code></pre>
<h3 id='initializing_a_new_git_repo'>initializing a new git repo</h3>
<p>To initialize a Git repository from an existing directory, simply type <code>git init</code> while in that directory. That will create the skeleton of the basic Git repository for you in that directory.</p>
<pre><code>$ rails myproject
$ cd myproject
$ git init</code></pre>
<p>Now you have an empty git repository (you can see the new ‘.git’ directory there). Now you can stage and commit files to it with the <code>git add</code> and <code>git commit</code> commands. We’ll cover these commands in depth in the next session.</p>
<pre><code>$ git add .
$ git commit -m 'initial commit'</code></pre>
<p>Now you have a full Git repository with a commit in it, and you can run commands like <code>git log</code> on it to see the history of the project (which we’ll cover in depth later).</p>
<pre><code>$ git log
commit eac2f939e6a1cb3189fedd19919888d998ab0431
Author: Scott Chacon <schacon@gmail.com>
Date: Sun Feb 8 07:55:57 2009 -0800
initial commit</code></pre>
<h3 id='cloning_a_git_repo'>cloning a git repo</h3>
<p>There are a number of protocols that Git can communicate over, but the three main ones we’ll deal with are ssh, http and the git protocol (a simple protocol used just for git).</p>
<p>For anonymous access, it is generally over git:// or http. To clone a repository over any protocol, simply type <code>git clone [url]</code>, where the <em>url</em> is something like “git://(hostname)/(path).git”</p>
<pre><code>$ git clone git://github.com/schacon/munger.git
$ cd munger
$ ls
README examples munger.gemspec
Rakefile lib spec</code></pre>
<p>You can also clone repositories over http in many cases. That looks largely the same, but with ‘http’ instead of ‘git’.</p>
<pre><code>$ git clone http://github.com/schacon/munger.git</code></pre>
<p>This is only available if the server has enabled it - if you are hosting your repository on GitHub, both git:// and http:// access are enabled.</p><br/><br/><hr/></div><div class="span-10"><a href="intro.html">« Introduction To Git</a></div><div style="text-align:right" class="span-11 last"><a href="normal.html">Normal Workflow »</a></div><div class="span-24 last"> </div><hr/>
</div>
<div id="footer" class="span-21">
<div class="info span-12">
<div class="links">
<a href="https://github.com/blog/148-github-shirts-now-available">T-Shirts</a> |
<a href="https://github.com/blog">Blog</a> |
<a href="https://github.com/contact">Contact & Support </a> |
<a href="http://training.github.com/">Git Training</a> |
<a href="https://status.github.com">Status</a>
</div>
<div class="company">
© 2012 GitHub Inc. All rights reserved. | <a href="https://help.github.com/articles/github-terms-of-service">Terms of Service</a> | <a href="https://help.github.com/articles/github-privacy-policy">Privacy Policy</a>
</div>
</div>
<div class="fork span-7">
This website is <a href="http://github.com/github/learn.github.com">open source</a>.
Please help us by forking the project and adding to it.
</div>
</div>
</div>
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3769691-2");
pageTracker._initData();
pageTracker._trackPageview();
</script>
</body>
</html>