Skip to content

Commit 6e34d9e

Browse files
author
Songyu
committed
增加文章,github分类下
1 parent e8e30f8 commit 6e34d9e

File tree

11 files changed

+213
-54
lines changed

11 files changed

+213
-54
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
---
2+
layout: post
3+
title: "git 生成补丁和打补丁"
4+
date: 2020-05-07 14:17:10 +0800
5+
tags: github
6+
description:
7+
---
8+
9+
最近在维护的一个项目,突然转移到了内网,不能直接用git pull命令进行更新了,手动替换的话,又不太方便,运用diff命令进行打包,批量替换的话,对于每次的修改日志又没办法统一的很好,于是想到git生成补丁和打补丁这个操作
10+
11+
### 生成补丁
12+
13+
对于生成补丁,比较简单,基本也不会发生太大的问题,就记录几条简单的命令
14+
{% highlight github %}
15+
//生成某次提交之后的补丁
16+
git format-patch COMMIT-ID
17+
//生成某次提交之后,n = 1时获取当前提交的补丁
18+
git format-patch -n COMMIT-ID
19+
{% endhighlight %}
20+
format-patch默认生成补丁的编号是从1开始,后面追加 **--start-number=NUMBER** 命令,可以生成指定编号
21+
22+
准备好生成的补丁,就可以转移到内网环境,进行打补丁操作了~
23+
24+
### 应用补丁
25+
26+
打补丁命令如下:
27+
{% highlight github %}
28+
//查看补丁中的信息修改
29+
git apply --stat PATH-FILE
30+
//检查是否能应用成功
31+
git apply --check PATH-FILE
32+
//应用补丁
33+
git am PATH-FILE
34+
{% endhighlight %}
35+
36+
应用补丁成功后,会直接显示补丁的commit信息,如果发生冲突的话,会输入以下信息
37+
![](/images/2020-05-07-1.jpg)
38+
39+
如果发生这种情况的话,可以执行如下命令
40+
{% highlight github %}
41+
git apply --reject PATH-FILE
42+
{% endhighlight %}
43+
git会先将补丁中的未冲突部分,进行合并,然后对于冲突的文件,会生成同目录下,同名的.rej文件,文件中可以查看变动记录
44+
对比文件后,将修改文件提交到暂存区,然后执行
45+
{% highlight github %}
46+
git am PATH-FILE --resolved
47+
{% endhighlight %}
48+
就可以将补丁成功进行应用
49+
50+
51+
运用这种方式,就可以保证我在本地和内网环境中的commit信息保持一致,同时,如果在内网维护时出现的问题,也可以直接生成补丁,应用到本地中,大大提高了代码的可维护性

images/2020-05-07-1.jpg

15.5 KB
Loading

tag/docker/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ <h2 class="post_title">标签分类 "docker&rdquo;</h2>
110110

111111

112112

113+
114+
115+
116+
117+
118+
119+
120+
113121

114122

115123

@@ -264,16 +272,16 @@ <h2 class="post-title">
264272
<h2>近期文章</h2>
265273
<ul>
266274

275+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
276+
277+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
278+
267279
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
268280

269281
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
270282

271283
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
272284

273-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
274-
275-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
276-
277285
</ul>
278286
</div>
279287

@@ -287,7 +295,7 @@ <h2>文章分类</h2>
287295
<span>docker</span></a></li>
288296

289297
<li>
290-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
298+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
291299
<span>github</span></a></li>
292300

293301
<li>
@@ -315,7 +323,7 @@ <h2>文章分类</h2>
315323
<span>心情</span></a></li>
316324

317325
<li>
318-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
326+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
319327
<span>杂谈</span></a></li>
320328

321329
</ul>

tag/github/index.html

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,32 @@ <h2 class="post_title">标签分类 "github&rdquo;</h2>
5555

5656

5757

58+
<h2 class="post-title">
59+
<a href="https://GuoSongyu.github.io/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">
60+
git 生成补丁和打补丁
61+
</a>
62+
</h2>
63+
64+
<div class="post-meta">
65+
<div class="post-time">
66+
<i class="fa fa-calendar"></i>
67+
<time datetime='2020-05-07'>07 May 2020</time>
68+
</div>
69+
</div>
70+
<div class="post-descr">
71+
<p>
72+
73+
</p>
74+
</div>
75+
76+
77+
78+
79+
80+
81+
82+
83+
5884

5985

6086

@@ -300,16 +326,16 @@ <h2 class="post-title">
300326
<h2>近期文章</h2>
301327
<ul>
302328

329+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
330+
331+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
332+
303333
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
304334

305335
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
306336

307337
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
308338

309-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
310-
311-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
312-
313339
</ul>
314340
</div>
315341

@@ -323,7 +349,7 @@ <h2>文章分类</h2>
323349
<span>docker</span></a></li>
324350

325351
<li>
326-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
352+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
327353
<span>github</span></a></li>
328354

329355
<li>
@@ -351,7 +377,7 @@ <h2>文章分类</h2>
351377
<span>心情</span></a></li>
352378

353379
<li>
354-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
380+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
355381
<span>杂谈</span></a></li>
356382

357383
</ul>

tag/jekyll/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,14 @@ <h2 class="post_title">标签分类 "jekyll&rdquo;</h2>
102102

103103

104104

105+
106+
107+
108+
109+
110+
111+
112+
105113

106114

107115

@@ -318,16 +326,16 @@ <h2 class="post-title">
318326
<h2>近期文章</h2>
319327
<ul>
320328

329+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
330+
331+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
332+
321333
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
322334

323335
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
324336

325337
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
326338

327-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
328-
329-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
330-
331339
</ul>
332340
</div>
333341

@@ -341,7 +349,7 @@ <h2>文章分类</h2>
341349
<span>docker</span></a></li>
342350

343351
<li>
344-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
352+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
345353
<span>github</span></a></li>
346354

347355
<li>
@@ -369,7 +377,7 @@ <h2>文章分类</h2>
369377
<span>心情</span></a></li>
370378

371379
<li>
372-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
380+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
373381
<span>杂谈</span></a></li>
374382

375383
</ul>

tag/nginx/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ <h2 class="post_title">标签分类 "nginx&rdquo;</h2>
5555

5656

5757

58+
59+
60+
61+
62+
63+
64+
65+
5866
<h2 class="post-title">
5967
<a href="https://GuoSongyu.github.io/2020/02/nginx%E6%97%A5%E5%BF%97">
6068
nginx日志
@@ -462,16 +470,16 @@ <h2 class="post-title">
462470
<h2>近期文章</h2>
463471
<ul>
464472

473+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
474+
475+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
476+
465477
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
466478

467479
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
468480

469481
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
470482

471-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
472-
473-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
474-
475483
</ul>
476484
</div>
477485

@@ -485,7 +493,7 @@ <h2>文章分类</h2>
485493
<span>docker</span></a></li>
486494

487495
<li>
488-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
496+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
489497
<span>github</span></a></li>
490498

491499
<li>
@@ -513,7 +521,7 @@ <h2>文章分类</h2>
513521
<span>心情</span></a></li>
514522

515523
<li>
516-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
524+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
517525
<span>杂谈</span></a></li>
518526

519527
</ul>

tag/php/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,14 @@ <h2 class="post_title">标签分类 "php&rdquo;</h2>
146146

147147

148148

149+
150+
151+
152+
153+
154+
155+
156+
149157

150158

151159

@@ -318,16 +326,16 @@ <h2 class="post-title">
318326
<h2>近期文章</h2>
319327
<ul>
320328

329+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
330+
331+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
332+
321333
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
322334

323335
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
324336

325337
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
326338

327-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
328-
329-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
330-
331339
</ul>
332340
</div>
333341

@@ -341,7 +349,7 @@ <h2>文章分类</h2>
341349
<span>docker</span></a></li>
342350

343351
<li>
344-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
352+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
345353
<span>github</span></a></li>
346354

347355
<li>
@@ -369,7 +377,7 @@ <h2>文章分类</h2>
369377
<span>心情</span></a></li>
370378

371379
<li>
372-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
380+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
373381
<span>杂谈</span></a></li>
374382

375383
</ul>

tag/web/index.html

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,14 @@ <h2 class="post_title">标签分类 "web&rdquo;</h2>
194194

195195

196196

197+
198+
199+
200+
201+
202+
203+
204+
197205

198206

199207

@@ -264,16 +272,16 @@ <h2 class="post-title">
264272
<h2>近期文章</h2>
265273
<ul>
266274

275+
<li><a href="/2020/05/git-%E7%94%9F%E6%88%90%E8%A1%A5%E4%B8%81%E5%92%8C%E6%89%93%E8%A1%A5%E4%B8%81">git 生成补丁和打补丁</a></li>
276+
277+
<li><a href="/2020/03/windwos%E5%AE%89%E8%A3%85%E9%85%8D%E7%BD%AEmaven">Windwos安装配置maven</a></li>
278+
267279
<li><a href="/2020/02/nginx%E6%97%A5%E5%BF%97">nginx日志</a></li>
268280

269281
<li><a href="/2020/02/nginx%E9%85%8D%E7%BD%AEssl">nginx配置SSL</a></li>
270282

271283
<li><a href="/2020/02/nginx%E8%AE%BF%E9%97%AE%E6%8E%A7%E5%88%B6">nginx访问控制</a></li>
272284

273-
<li><a href="/2020/02/nginx%E8%B4%9F%E8%BD%BD%E5%9D%87%E8%A1%A1">nginx负载均衡</a></li>
274-
275-
<li><a href="/2020/02/nginx%E4%BB%A3%E7%90%86">nginx代理</a></li>
276-
277285
</ul>
278286
</div>
279287

@@ -287,7 +295,7 @@ <h2>文章分类</h2>
287295
<span>docker</span></a></li>
288296

289297
<li>
290-
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="4">
298+
<a href="/tag/github" data-toggle="tooltip" data-placement="right" title="5">
291299
<span>github</span></a></li>
292300

293301
<li>
@@ -315,7 +323,7 @@ <h2>文章分类</h2>
315323
<span>心情</span></a></li>
316324

317325
<li>
318-
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="4">
326+
<a href="/tag/杂谈" data-toggle="tooltip" data-placement="right" title="5">
319327
<span>杂谈</span></a></li>
320328

321329
</ul>

0 commit comments

Comments
 (0)