-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathgit-ru-men.html
More file actions
202 lines (188 loc) · 10.7 KB
/
git-ru-men.html
File metadata and controls
202 lines (188 loc) · 10.7 KB
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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
<!DOCTYPE html>
<html lang="en-US">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="author" content="Won" />
<meta name="copyright" content="Won" />
<meta name="keywords" content="Git, It, " />
<title>Git 入门 · Tugqi Biz
</title>
<link href="http://cdn-images.mailchimp.com/embedcode/slim-081711.css" rel="stylesheet" type="text/css">
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/css/bootstrap-combined.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" href="http://wbowam.github.io/theme/css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="http://wbowam.github.io/theme/css/solarizedlight.css" media="screen">
<link rel="shortcut icon" href="http://wbowam.github.io/theme/images/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="http://wbowam.github.io/theme/images/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="57x57" href="http://wbowam.github.io/theme/images/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="http://wbowam.github.io/theme/images/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="http://wbowam.github.io/theme/images/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="http://wbowam.github.io/theme/images/apple-touch-icon-144x144.png" />
<link rel="icon" href="http://wbowam.github.io/theme/images/apple-touch-icon-144x144.png" />
</head>
<body>
<div id="content-sans-footer">
<div class="navbar navbar-static-top">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<a class="brand" href="http://wbowam.github.io/"><span class=site-name>Tugqi Biz</span></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right top-menu">
<li ><a href="http://wbowam.github.io">Home</a></li>
<li ><a href="http://wbowam.github.io/categories.html">Categories</a></li>
<li ><a href="http://wbowam.github.io/tags.html">Tags</a></li>
<li ><a href="http://wbowam.github.io/archives.html">Archives</a></li>
<li><form class="navbar-search" action="http://wbowam.github.io/search.html" onsubmit="return validateForm(this.elements['q'].value);"> <input type="text" class="search-query" placeholder="Search" name="q" id="tipue_search_input"></form></li>
</ul>
</div>
</div>
</div>
</div>
<div class="container-fluid">
<div class="row-fluid">
<div class="span1"></div>
<div class="span10">
<article>
<div class="row-fluid">
<header class="page_header span10">
<h1><a href="http://wbowam.github.io/git-ru-men.html"> Git 入门 </a></h1>
</header>
</div>
<div class="row-fluid">
<div class="span10 article-content">
<p>之前入门过git,只是入门,不明白原理,不会用建分支,没法完成一些稍有难度的工作。因此,一直想再学学,一直是想,直到......<br />
好朋友wwj推荐<a href="http://igit.linuxtoy.org/">沉浸式学 Git</a>,看了一下:特别喜欢,再学学,走起!
感谢<a href="http://igit.linuxtoy.org/">徐小东</a>,感谢<a href="http://wwj718.github.io/">wwj</a>.</p>
<hr />
<h3 id="_1">安装<a class="headerlink" href="#_1" title="Permanent link">¶</a></h3>
<h5 id="linux">Linux<a class="headerlink" href="#linux" title="Permanent link">¶</a></h5>
<p><code>$ apt-get install git</code> <br />
Or <br />
<code>$ yum install git-core</code></p>
<h5 id="mac">Mac<a class="headerlink" href="#mac" title="Permanent link">¶</a></h5>
<p>请参阅<a href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Mac 安装Git</a></p>
<h5 id="windows">windows<a class="headerlink" href="#windows" title="Permanent link">¶</a></h5>
<p>请参阅 <a href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Windows 安装Git</a></p>
<hr />
<h3 id="_2">开始使用<a class="headerlink" href="#_2" title="Permanent link">¶</a></h3>
<h4 id="1">1. 创建新仓库<a class="headerlink" href="#1" title="Permanent link">¶</a></h4>
<div class="highlight"><pre><span class="n">mkdir</span> <span class="n">hello</span>
<span class="n">cd</span> <span class="n">hello</span>
<span class="n">git</span> <span class="n">init</span>
</pre></div>
<p>添加新内容
<code>vim hello.rb</code><br />
<code>git add hello.rb</code>或<code>git add .</code> <br />
添加注释 </p>
<div class="highlight"><pre><span class="n">git</span> <span class="n">commit</span> <span class="o">-</span><span class="n">m</span> <span class="s">"First Commit"</span>
</pre></div>
<p>推送改动<br />
<code>git push origin master</code> </p>
<h4 id="2">2. 检查仓库状态<a class="headerlink" href="#2" title="Permanent link">¶</a></h4>
<p><code>git status</code></p>
<h4 id="3-history">3. 查看历史(history)<a class="headerlink" href="#3-history" title="Permanent link">¶</a></h4>
<p>本地 <br />
<code>git log</code><br />
线上的版本<br />
<code>git log --pretty=oneline</code> </p>
<h4 id="4">4.改命令别名<a class="headerlink" href="#4" title="Permanent link">¶</a></h4>
<p>这个很有用。以前重复敲很多很长的命令——烦!这下好了'.'</p>
<h6 id="gitconfig">找到.gitconfig,记得先备份一下啊<a class="headerlink" href="#gitconfig" title="Permanent link">¶</a></h6>
<div class="highlight"><pre><span class="k">[alias]</span>
<span class="na">co</span> <span class="o">=</span> <span class="s">checkout</span>
<span class="s"> ci = commit</span>
<span class="s"> st = status</span>
<span class="s"> br = branch</span>
<span class="s"> hist = log --pretty=format:'%h %ad | %s%d [%an]' --graph --date=short</span>
<span class="s"> type = cat-file -t</span>
<span class="s"> dump = cat-file -p</span>
</pre></div>
<h4 id="5">5.检出仓库<a class="headerlink" href="#5" title="Permanent link">¶</a></h4>
<h6 id="_3">执行如下命令以创建一个本地仓库的克隆版本:<a class="headerlink" href="#_3" title="Permanent link">¶</a></h6>
<p><code>git clone /path/to/repository</code> </p>
<h5 id="_4">创建一个远程仓库的克隆版本:<a class="headerlink" href="#_4" title="Permanent link">¶</a></h5>
<p><code>git clone username@host:/path/to/repository</code></p>
<h3 id="6">6.分支<a class="headerlink" href="#6" title="Permanent link">¶</a></h3>
<p>分支是用来将特性开发绝缘开来的。在你创建仓库的时候,master 是“默认的”。在其他分支上进行开发,完成后再将它们合并到主分支上。<a href="http://www.bootcss.com/p/git-guide/img/branches.png">原理图</a> </p>
<h5 id="feature_x">创建一个叫做“feature_x”的分支,并切换过去:<a class="headerlink" href="#feature_x" title="Permanent link">¶</a></h5>
<p><code>git checkout -b feature_x</code></p>
<h6 id="_5">切换回主分支:<a class="headerlink" href="#_5" title="Permanent link">¶</a></h6>
<p><code>git checkout master</code></p>
<h6 id="feature_x_1">再切换到分支feature_x:<a class="headerlink" href="#feature_x_1" title="Permanent link">¶</a></h6>
<p><code>git checkout feature_x</code></p>
<h5 id="_6">删除分支<a class="headerlink" href="#_6" title="Permanent link">¶</a></h5>
<p><code>git branch -d feature_x</code> </p>
<h6 id="_7"><strong>所有的操作之后别忘了推送</strong><a class="headerlink" href="#_7" title="Permanent link">¶</a></h6>
<h4 id="7">7.更新与合并<a class="headerlink" href="#7" title="Permanent link">¶</a></h4>
<p>更新<br />
<code>git pull</code>
合并<br />
<code>git merge <branch></code></p>
<hr />
<p>先就这些吧,谢谢光顾!</p>
<aside>
<hr/>
<nav>
<ul class="articles_timeline">
<li class="previous_article">« <a href="http://wbowam.github.io/git-qu-xiao-cuo-wu-de-shang-chuan.html" title="Previous: git 取消错误的上传">git 取消错误的上传</a></li>
<li class="next_article"><a href="http://wbowam.github.io/django-userena-de-shi-yong.html" title="Next: Django-userena 的使用">Django-userena 的使用</a> »</li>
</ul>
</nav>
</aside>
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread" data-author-key="4433755"></div>
<script type="text/javascript">
var duoshuoQuery = {short_name:"tlbog"};
(function() {
var ds = document.createElement('script');
ds.type = 'text/javascript';ds.async = true;
ds.src = 'http://static.duoshuo.com/embed.js';
ds.charset = 'UTF-8';
(document.getElementsByTagName('head')[0]
|| document.getElementsByTagName('body')[0]).appendChild(ds);
})();
</script>
<!-- Duoshuo Comment END -->
</div>
<section>
<div class="span2" style="float:right;font-size:0.9em;">
<h4>Published</h4>
<time pubdate="pubdate" datetime="2013-09-08T00:00:00+08:00">Sep 8, 2013</time>
<h4>Category</h4>
<a class="category-link" href="/categories.html#It-ref">It</a>
<h4>Tags</h4>
<ul class="list-of-tags tags-in-article">
<li><a href="/tags.html#Git-ref">Git
<span>8</span>
</a></li>
</ul>
</div>
</section>
</div>
</article>
</div>
<div class="span1"></div>
</div>
</div>
</div>
<footer>
<div id="footer">
<ul class="footer-content">
<li class="elegant-power">Powered by <a href="http://getpelican.com/" title="Pelican Home Page">Pelican</a>. Theme: <a href="http://oncrashreboot.com/pelican-elegant" title="Theme Elegant Home Page">Elegant</a> by <a href="http://oncrashreboot.com" title="Talha Mansoor Home Page">Talha Mansoor</a></li>
</ul>
</div>
</footer> <script src="http://code.jquery.com/jquery.min.js"></script>
<script src="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.1/js/bootstrap.min.js"></script>
<script>
function validateForm(query)
{
return (query.length > 0);
}
</script>
</body>
</html>