-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-ru-men.html
More file actions
223 lines (197 loc) · 8.68 KB
/
git-ru-men.html
File metadata and controls
223 lines (197 loc) · 8.68 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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<!DOCTYPE html>
<!--[if IEMobile 7 ]><html class="no-js iem7"><![endif]-->
<!--[if lt IE 9]><html class="no-js lte-ie8"><![endif]-->
<!--[if (gt IE 8)|(gt IEMobile 7)|!(IEMobile)|!(IE)]><!--><html class="no-js" lang="en"><!--<![endif]-->
<head>
<link rel="short icon" href="http://softing.qiniudn.com/20140603011448867_easyicon_net_128.ico" type="image/x-ico">
<meta charset="utf-8">
<title>Git 入门</title>
<meta name="author" content="tulpar">
<!-- http://t.co/dKP3o1e -->
<meta name="HandheldFriendly" content="True">
<meta name="MobileOptimized" content="320">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- <link href="/favicon.png" rel="icon"> -->
<link href="/theme/css/main.css" media="screen, projection"
rel="stylesheet" type="text/css">
<script src="/theme/js/modernizr-2.0.js"></script>
<script src="/theme/js/ender.js"></script>
<script src="/theme/js/octopress.js" type="text/javascript"></script>
<link href="http://fonts.googleapis.com/css?family=PT+Serif:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
<link href="http://fonts.googleapis.com/css?family=PT+Sans:regular,italic,bold,bolditalic"
rel="stylesheet" type="text/css">
</head>
<body>
<header role="banner"><hgroup>
<h1><a href="/">Dreaming</a></h1>
</hgroup></header>
<nav role="navigation"><ul class="subscription" data-subscription="rss">
</ul>
<ul class="main-navigation">
<li class="active">
<a href="/category/it.html">It</a>
</li>
<li >
<a href="/category/life.html">Life</a>
</li>
</ul></nav>
<div id="main">
<div id="content">
<div>
<article class="hentry" role="article">
<header>
<h1 class="entry-title">Git 入门</h1>
<p class="meta"><time datetime="2013-09-08T00:00:00+08:00" pubdate>Sun 08 September 2013</time></p>
</header>
<div class="entry-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>安装</h3>
<h5>Linux</h5>
<p><code>$ apt-get install git</code> <br />
Or <br />
<code>$ yum install git-core</code></p>
<h5>Mac</h5>
<p>请参阅<a href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Mac 安装Git</a></p>
<h5>windows</h5>
<p>请参阅 <a href="http://git-scm.com/book/en/Getting-Started-Installing-Git">Windows 安装Git</a></p>
<hr />
<h3>开始使用</h3>
<h4>1. 创建新仓库</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>2. 检查仓库状态</h4>
<p><code>git status</code></p>
<h4>3. 查看历史(history)</h4>
<p>本地 <br />
<code>git log</code><br />
线上的版本<br />
<code>git log --pretty=oneline</code> </p>
<h4>4.改命令别名</h4>
<p>这个很有用。以前重复敲很多很长的命令——烦!这下好了'.'</p>
<h6>找到.gitconfig,记得先备份一下啊</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>5.检出仓库</h4>
<h6>执行如下命令以创建一个本地仓库的克隆版本:</h6>
<p><code>git clone /path/to/repository</code> </p>
<h5>创建一个远程仓库的克隆版本:</h5>
<p><code>git clone username@host:/path/to/repository</code></p>
<h3>6.分支</h3>
<p>分支是用来将特性开发绝缘开来的。在你创建仓库的时候,master 是“默认的”。在其他分支上进行开发,完成后再将它们合并到主分支上。<a href="http://www.bootcss.com/p/git-guide/img/branches.png">原理图</a> </p>
<h5>创建一个叫做“feature_x”的分支,并切换过去:</h5>
<p><code>git checkout -b feature_x</code></p>
<h6>切换回主分支:</h6>
<p><code>git checkout master</code></p>
<h6>再切换到分支feature_x:</h6>
<p><code>git checkout feature_x</code></p>
<h5>删除分支</h5>
<p><code>git branch -d feature_x</code> </p>
<h6><strong>所有的操作之后别忘了推送</strong></h6>
<h4>7.更新与合并</h4>
<p>更新<br />
<code>git pull</code>
合并<br />
<code>git merge <branch></code></p>
<hr />
<p>先就这些吧,谢谢光顾!</p></div>
<footer>
<p class="meta">
<span class="byline author vcard">
Posted by <span class="fn">tulpar</span>
</span>
<time datetime="2013-09-08T00:00:00+08:00" pubdate>Sun 08 September 2013</time> <span class="categories">
<a class="category" href="/tag/git.html">Git</a>
</span>
</p><div class="sharing">
</div> </footer>
</article>
<!-- Duoshuo Comment BEGIN -->
<div class="ds-thread"></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>
<aside class="sidebar">
<section>
<h1>Recent Posts</h1>
<ul id="recent_posts">
<li class="post">
<a href="/xie-bo-ke-jiao-ben.html">写博客脚本</a>
</li>
<li class="post">
<a href="/gong-zuo-shi-de-sui-bi.html">工作时的随笔</a>
</li>
<li class="post">
<a href="/ce-shi-wen-zhang.html">测试文章</a>
</li>
<li class="post">
<a href="/djangokai-qi-the-sites-framework.html">Django开启 the sites framework</a>
</li>
<li class="post">
<a href="/django-17shi-yong.html">Django 1.7试用</a>
</li>
</ul>
</section>
<section>
<h1>Categories</h1>
<ul id="recent_posts">
<li><a href="/category/it.html">It</a></li>
<li><a href="/category/life.html">Life</a></li>
</ul>
</section>
<section>
<h1>Tags</h1>
<a href="/tag/mysql.html">Mysql</a>, <a href="/tag/tmux.html">Tmux</a>, <a href="/tag/fan-qiang.html">翻墙</a>, <a href="/tag/linux.html">Linux</a>, <a href="/tag/edx.html">Edx</a>, <a href="/tag/virtualbox.html">VirtualBox</a>, <a href="/tag/wo-ai-wo-jia.html">我爱我家</a>, <a href="/tag/userena.html">userena</a>, <a href="/tag/xadmin.html">Xadmin</a>, <a href="/tag/shell.html">Shell</a>, <a href="/tag/python.html">Python</a>, <a href="/tag/djangopython.html">Django,python</a>, <a href="/tag/ssh.html">ssh</a>, <a href="/tag/ubuntu.html">Ubuntu</a>, <a href="/tag/git.html">Git</a>, <a href="/tag/ce-shi.html">测试</a>, <a href="/tag/ueditor.html">Ueditor</a>, <a href="/tag/github.html">Github</a>, <a href="/tag/socketio.html">Socket.io</a>, <a href="/tag/django.html">Django</a>, <a href="/tag/du-shu.html">读书</a>, <a href="/tag/bo-ke.html">博客</a>, <a href="/tag/ngrok.html">ngrok</a> </section>
<section>
<h1>Social</h1>
<ul>
<li><a href="http://izda.com" target="_blank">ئىزدە</a></li>
<li><a href="http://www.google.com" target="_blank">Google</a></li>
<li><a href="http://www.zhihu.com/" target="_blank">知乎</a></li>
<li><a href="http://www.douban.com/" target="_blank">豆瓣</a></li>
</ul>
</section>
<section>
<h1>Blogroll</h1>
<ul>
<li><a href="https://github.com/tulpar008" target="_blank">My Github</a></li>
<li><a href="#" target="_blank">tulpar008@gmail.com</a></li>
</ul>
</section>
</aside> </div>
</div>
<footer role="contentinfo"><p>
Copyright © 2013-2015 - tulpar -
<span class="credit">Powered by <a href="http://getpelican.com">Pelican</a></span>
</p></footer>
</body>
</html>