forked from WBowam/wbowam.github.com
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-fu-xi-gong-gu-4.html
More file actions
145 lines (133 loc) · 7.21 KB
/
git-fu-xi-gong-gu-4.html
File metadata and controls
145 lines (133 loc) · 7.21 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
<!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="tulpar" />
<meta name="copyright" content="tulpar" />
<meta name="keywords" content="git, It, " />
<title>git 复习巩固(4) · Dreaming
</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="/theme/css/style.css" media="screen">
<link rel="stylesheet" type="text/css" href="/theme/css/solarizedlight.css" media="screen">
<link rel="shortcut icon" href="/theme/images/favicon.ico" type="image/x-icon" />
<link rel="apple-touch-icon" href="/theme/images/apple-touch-icon.png" />
<link rel="apple-touch-icon" sizes="57x57" href="/theme/images/apple-touch-icon-57x57.png" />
<link rel="apple-touch-icon" sizes="72x72" href="/theme/images/apple-touch-icon-72x72.png" />
<link rel="apple-touch-icon" sizes="114x114" href="/theme/images/apple-touch-icon-114x114.png" />
<link rel="apple-touch-icon" sizes="144x144" href="/theme/images/apple-touch-icon-144x144.png" />
<link rel="icon" href="/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="/"><span class=site-name>Dreaming</span></a>
<div class="nav-collapse collapse">
<ul class="nav pull-right top-menu">
<li ><a href="">Home</a></li>
<li ><a href="/categories.html">Categories</a></li>
<li ><a href="/tags.html">Tags</a></li>
<li ><a href="/archives.html">Archives</a></li>
<li><form class="navbar-search" action="/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 offset2">
<h1><a href="/git-fu-xi-gong-gu-4.html"> git 复习巩固(4) </a></h1>
</header>
</div>
<div class="row-fluid">
<div class="span8 offset2 article-content">
<h3>分支</h3>
<h4># 新建分支</h4>
<p><code>git branch branch-name</code></p>
<h5>新建并切到该分支</h5>
<p><code>git checkout -b branch-name</code></p>
<h5>删除分支</h5>
<p><code>$ git branch -d experimental</code></p>
<h6>-d只能删除那些已经被当前分支的合并的分支.</h6>
<h5>强制删除某个分支的话就用 –D</h5>
<p><code>$ git branch -D crazy-idea</code> </p>
<h4>合并冲突</h4>
<div class="highlight"><pre><span class="n">git</span> <span class="n">merge</span> <span class="n">branch</span><span class="o">-</span><span class="n">name</span>
<span class="mi">100</span><span class="o">%</span> <span class="p">(</span><span class="mi">4</span><span class="o">/</span><span class="mi">4</span><span class="p">)</span> <span class="n">done</span>
<span class="n">Auto</span><span class="o">-</span><span class="n">merged</span> <span class="n">file</span><span class="p">.</span><span class="n">txt</span>
<span class="n">CONFLICT</span> <span class="p">(</span><span class="n">content</span><span class="p">)</span><span class="o">:</span> <span class="n">Merge</span> <span class="n">conflict</span> <span class="n">in</span> <span class="n">file</span><span class="p">.</span><span class="n">txt</span>
<span class="n">Automatic</span> <span class="n">merge</span> <span class="n">failed</span><span class="p">;</span> <span class="n">fix</span> <span class="n">conflicts</span> <span class="n">and</span> <span class="n">then</span> <span class="n">commit</span> <span class="n">the</span> <span class="n">result</span><span class="p">.</span>
</pre></div>
<h5>解决合并中的冲突</h5>
<p>有冲突(conflicts)的文件会保存在索引中,除非你解决了问题了并且更新了索引,否则执行 git commit都会失败:</p>
<div class="highlight"><pre><span class="n">git</span> <span class="n">commit</span>
<span class="n">file</span><span class="p">.</span><span class="n">txt</span><span class="o">:</span> <span class="n">needs</span> <span class="n">merge</span>
</pre></div>
<h4>撒销一个合并</h4>
<p>放弃修改撤回到本分支头部
<code>git reset --hard HEAD</code> <br />
或
<code>git checkout -f</code> <br />
撤回到之前的commit
<code>git reset 4ba467213eb73480431b95c7dba03aac1c7a2c26</code></p>
<aside>
<hr/>
<nav>
<ul class="articles_timeline">
<li class="previous_article">« <a href="/git-fu-xi-gong-gu-5.html" title="Previous: git 复习巩固(5)">git 复习巩固(5)</a></li>
<li class="next_article"><a href="/git-fu-xi-gong-gu-3.html" title="Next: git 复习巩固(3)">git 复习巩固(3)</a> »</li>
</ul>
</nav>
</aside>
</div>
<section>
<div class="span2" style="float:right;font-size:0.9em;">
<h4>Published</h4>
<time pubdate="pubdate" datetime="2015-03-29T00:00:00+08:00">Mar 29, 2015</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>5</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>