Skip to content

Commit 85be7eb

Browse files
author
git
committed
提交文章
1 parent c741a6a commit 85be7eb

File tree

39 files changed

+683
-327
lines changed

39 files changed

+683
-327
lines changed
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
---
2+
layout: post
3+
title: "Git常用命令记录"
4+
description: ""
5+
category: articles
6+
tags: [Git]
7+
image:
8+
feature:
9+
credit: Michael Rose
10+
creditlink: http://mademistakes.com
11+
comments: true
12+
share: true
13+
---
14+
15+
日常使用 Git,有时会忘记使用频率不高的 Git 命令,记录在此,以供查询使用。
16+
17+
# 添加
18+
19+
## 添加修改后的文件
20+
21+
git add *
22+
git add *\.py
23+
git add <Filename>
24+
git add <Filename> <Filename>
25+
26+
# 分支
27+
28+
## 查看远程分支
29+
30+
git branch -a
31+
32+
## 删除远程分支
33+
34+
git push origin --delete <Branch Name>
35+
36+
### 推送空的分支到某个远程分支,等同与删除远程分支。
37+
git push origin :<Branch Name>
38+
39+
40+
# 标签
41+
42+
## 列出代码仓库中的所有标签
43+
44+
git tag
45+
46+
## 本地添加标签
47+
48+
git tag -a <Tag Name>
49+
git tag -a <Tag Name> -m <Tag Message>
50+
51+
## 删除本地标签
52+
53+
git tag -d <Tag Name>
54+
55+
## 删除远程标签
56+
57+
git push origin --delete tag <tagname>
58+
59+
### 推送空的标签到远程标签,等同与删除远程标签。
60+
61+
git tag -d <Tag Name>
62+
git push origin :refs/tags/<Tag Name>
63+
64+
## 推送某个标签到远程标签
65+
66+
git push origin v0.4.0.20171214_alpha
67+
68+
## 推送全部本地标签到远程标签
69+
70+
git push --tags
71+
72+
## 获取某个远程标签下的代码
73+
74+
git fetch origin tag <Tag Name>
75+
76+
## 重命名标签
77+
78+
git tag <New Tag Name> <Old Tag Name> # 从旧标签中创建新标签
79+
git tag -d <Old Tag Name> # 删除本地旧标签
80+
git push origin :refs/tags/<Old Tag Name> # 删除远程旧标签
81+
git push --tags # 推送至远程仓库
82+
83+
如果有其他本地仓库存在已删除的旧标签,则运行以下命令来更新本地仓库的标签
84+
85+
git pull --prune --tags
86+
87+
# 撤销更改
88+
89+
## 已修改,未暂存
90+
91+
git checkout .
92+
93+
git reset --hard
94+
95+
## 已暂存,未提交
96+
97+
git reset
98+
git checkout .
99+
100+
git reset --hard
101+
102+
## 已提交,未推送
103+
104+
git reset --hard origin/master
105+
106+
## 已推送
107+
108+
git reset --hard HEAD^
109+
git push -f

_site/404/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ <h1 class="entry-title">Page Not Found</h1>
142142

143143
<div class="footer-wrapper">
144144
<footer role="contentinfo">
145-
<span>&copy; 2017 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
145+
<span>&copy; 2018 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
146146
<div class="social-icons">
147147

148148

_site/about/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ <h2 id="参与-open-source-projects">参与 Open Source Projects</h2>
177177

178178
<div class="footer-wrapper">
179179
<footer role="contentinfo">
180-
<span>&copy; 2017 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
180+
<span>&copy; 2018 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
181181
<div class="social-icons">
182182

183183

_site/articles/Do_I_need_a_content_type_for_http_get-requests/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ <h1 class="entry-title">Do I need a content type for http get requests?</h1>
165165

166166
<div class="footer-wrapper">
167167
<footer role="contentinfo">
168-
<span>&copy; 2017 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
168+
<span>&copy; 2018 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
169169
<div class="social-icons">
170170

171171

_site/articles/Failed-to-load-module-canberra-gtk-module/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ <h1 class="entry-title">Failed to load module canberra-gtk-module</h1>
167167

168168
<div class="footer-wrapper">
169169
<footer role="contentinfo">
170-
<span>&copy; 2017 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
170+
<span>&copy; 2018 Leo Zhang. Powered by <a href="http://jekyllrb.com">Jekyll</a> using the <a href="http://mademistakes.com/so-simple/">So Simple Theme</a>.</span>
171171
<div class="social-icons">
172172

173173

0 commit comments

Comments
 (0)