forked from jadijadi/gittutorial
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_commands.html
329 lines (301 loc) · 15.1 KB
/
git_commands.html
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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Git Commands</title>
<style>
html {
scroll-behavior: smooth;
}
body {
line-height: 1.5;
background: linear-gradient(to right, #e0eafc, #cfdef3);
/* W3C, IE 10+/ Edge, Firefox 16+, Chrome 26+, Opera 12+, Safari 7+ */
font-size: 1.5rem;
font-family: consolas;
}
a {
text-decoration: none;
color: black;
font-weight: bold;
display: inline-block;
line-height: 1.5;
}
li {
margin: 1rem 0;
}
b {
color: #747474;
}
b:not(.code) {
color: #ff0000;
}
h1 {
padding: 5px 20px;
}
.code {
padding: 0.3rem;
background-color: #f2f2f2;
border-radius: 5px;
color: #747474;
font-size: 1.6rem;
}
.sidebar {
font-size: 18px;
max-height: 100vh;
overflow-Y: auto;
position: fixed;
width: 20%;
font-family: Arial, Helvetica, sans-serif;
}
.sidebar li {
line-height: 1;
}
.main {
width: 80%;
float: right;
}
.part {
background: rgb(0, 8, 255);
margin: 30px 10px;
padding: 5px 15px;
color: white;
box-shadow: 0 0 16px 0px #00000056;
border-radius: 5px;
}
@media screen and (max-width: 1300px) {
.sidebar {
display: none
}
.main {
width: 100%;
}
}
</style>
</head>
<body>
<!-- sidebar -->
<aside class="sidebar">
<nav class="navbar">
<ul>
<li><a href="#general">General Commands</a></li>
<ul>
<li><a href="#config">git config</a></li>
<li><a href="#init">git init</a></li>
<li><a href="#status">git status</a></li>
<li><a href="#add">git add</a></li>
<li><a href="#commit">git commit</a></li>
<li><a href="#log">git log</a></li>
<li><a href="#diff">git diff <...></a></li>
<li><a href="#reset-filename">git reset filename</a></li>
<li><a href="#reset-commitHash">git reset commitHash</a></li>
<li><a href="#reset-commitHash-hard">git reset commitHash --hard</a></li>
<li><a href="#checkout--filename">git checkout -- filename</a></li>
<li><a href="#rm-filename">git rm filename</a></li>
</ul>
<li><a href="#Branchs">Branchs</a></li>
<ul>
<li><a href="#branch">git branch</a></li>
<li><a href="#branch-d">git branch -d branchName</a></li>
<li><a href="#checkout-branchName">git checkout branchName</a></li>
<li><a href="#merge-branchName">git merge branchName</a></li>
</ul>
<li><a href="#remoteAndClone">Remote & Clone</a></li>
<ul>
<li><a href="#clone">git clone gitAddress</a></li>
<li><a href="#remote-add">git remote add gitAddress</a></li>
<li><a href="#remote-v">git remote -v</a></li>
<li><a href="#push-origin-master">git push origin master</a></li>
<li><a href="#pull-origin-master">git pull origin master</a></li>
</ul>
<li><a href="#-tag">Tag</a></li>
<ul>
<li><a href="#tag">git tag</a></li>
<li><a href="#tag-a">git tag -a <...> -m ''</a></li>
<li><a href="#tag-a-commitHash">git tag -a <...> commitHash -m ''</a></li>
<li><a href="#tag-v">git tag -v <...> verifytag -v</a></li>
<li><a href="#show-tagName">git show tagName</a></li>
<li><a href="#push-origin-tagName">git push origin tagName</a></li>
<li><a href="#origin--tags">git push origin --tags</a></li>
<li><a href="#blame">git blame</a></li>
<li><a href="#pgp">pgp (gpg in openSource World)</a></li>
</ul>
<li><a href="#Bisect">Bisect</a></li>
<ul>
<li><a href="#bisect">git bisect</a></li>
</ul>
</ul>
</nav>
</aside>
<div class="main">
<h1>Git Commands</h1>
<!-- contetn -->
<section class="content">
<!-- start General Cammands -->
<section class="part">
<h2 id="general">General Commands</h2>
<ul>
<li id="config"><b class="code">git config --global user.name "USERNAME" :</b> config username
globaly </li>
<li id="config"><b class="code">git config --global user.email "USEREmail" :</b> config user email
globaly </li>
<li id="config"><b class="code">git config --global color.ui true :</b> show outputs colorful</li>
<li id="init"><b class="code">git init:</b> Git initilizing on Current Directory</li>
<li id="status"><b class="code">git status:</b> show modified,Untrackted and Staged Files </li>
<li id="add"><b class="code">git add:</b> Add Untrackted Or Modified File to <b>Stage</b></li>
<li id="add"><b class="code">git add . & git add -A:</b> These two commands add all untracked or
modified files to that
<b>Stage</b>
</li>
<li id="commit"><b class="code">git commit:</b> Commit Staged File and remove them from stage. after
commit all stages new
<li id="commit"><b class="code">git commit -m "Title" -m "message" :</b> Commit with Title and
Message
</li>
<li id="log"><b class="code">git log:</b> show a log of Commits with date, Descrtions and Author
Name</li>
<li id="log"><b class="code">git log --one-line --graph --all --decorate:</b> show logs like tree
with all branchs , ...</li>
<li id="diff"><b class="code">git diff <...>:</b> Comparison two Version of one file</li>
<ul> for Example:
<li>
<span class="code">git diff <b>HEAD</b>:</span> Comparison last committed state vs currnet
State for
All Modified
Files
</li>
<li>
<span class="code">git diff --staged:</span> Comparison last committed state of Staged files
vs current
state
</li>
</ul>
<li id="reset-filename"><b class="code">git reset filename:</b> unStage file</li>
<li id="reset-commitHash"><b class="code">git reset commitHash:</b> Back to specified commit ->
modifications will be unstaged (NOT Removed)</li>
<li id="reset-commitHash-hard"><b class="code">git reset commitHash --hard:</b> project FULLY
Returned to specified commit and modifications will be Removed</li>
<li id="checkout--filename"><b class="code">git checkout -- filename:</b> remove last modifications
in file and return file to last
committed
version</li>
<li id="rm-filename"><b class="code">git rm filename:</b> remove file from both git and system</li>
</ul>
</section>
<!-- start branches -->
<section class="part">
<h2 id="Branchs">-Branches-</h2>
<ul>
<li id="branch"><b class="code">git branch:</b> show list of All Branchs</li>
<li id="branch-d"><b class="code">git branch -d branchName:</b> Delete Branch</li>
<li id="checkout-branchName"><b class="code">git checkout branchName:</b> switch to branch with
name: branchName</li>
<li id="checkout-branchName"><b class="code">git checkout -b branchName:</b> creat and switch to
branch with name: branchName</li>
<li id="merge-branchName"><b class="code">git merge branchName:</b> merge 'branchName' branch into
current branch</li>
</ul>
</section>
<!-- start Remote & Clone -->
<section class="part">
<h2 id="remoteAndClone">-Remote & Clone-</h2>
<ul>
<li id="clone"><b class="code">git clone gitAddress:</b> Clone whole a repo to local with initilized
git</li>
<li id="remote-add"><b class="code">git remote add alias gitAddress:</b> add a Remote (alias like
origin) </li>
<li id="remote-v"><b class="code">git remote -v:</b> verbose Remotes (show full Info from remotes)
</li>
<li><b>Note:</b> we can have extra than ONE remote so for example we can add 3 remotes for Github,
Gitlab and
Company git Server</li>
<li><b>Note: origin:</b> original Branch we copied from that</li>
<li id="push-origin-master"><b class="code">git push origin master:</b> push changes from MASTER to
ORIGIN</li>
<li><b>Note:</b> since <b>October 1, 2020</b> any new repository will use <b class="code">main</b>
as the default branch, instead of master.<br>
so if you fork a <b>new</b> repo and make some changes, commits and you want to push it, use :
<b class="code">git push origin main</b>
</li>
<li><b>Note:</b> git push <b>-u</b> origin master: -u causes git to save 'origin master' so in next
steps it's
no need to write 'origin master':</li>
<li id="pull-origin-master"><b class="code">git pull origin master:</b> pull changes from ORIGIN to
MASTER</li>
<li><b>Note: git remote add</b> just creates an entry in your git config that specifies a name for a
particular
URL.
You must have an existing git repo to use this. <br>
<b class="code">git clone</b> creates a new git repository by copying an existing one located at
the URI
you specify.
</li>
</ul>
</section>
<!-- start Tag -->
<section class="part">
<h2 id="-tag">-Tag-</h2>
<ul>
<li id="tag"><b class="code">git tag:</b> show list of tags</li>
<li id="tag-a"><b class="code">git tag -a <...> -m '' :</b> set annotation (tag) with message like:
<span class="code">git tag -a v2.0 -m 'release Version 2.0'</span>
</li>
<li id="tag-a-commitHash"><b class="code">git tag -a <...> commitHash -m '' :</b> set annotation
(tag) with message for a COMMIT
</li>
<li><b class="code">git tag -v <...> verifytag -v :</b> show tag verify
</li>
<li><b class="code">git show tagName:</b> show full info about tag
</li>
<li><b class="code">git push origin tagName:</b> Regullary tags dont push to origin with other
changes and we
should push them manually
</li>
<li><b class="code">git push origin --tags:</b> like above for push all tags
</li>
<li><b class="code">git blame </b> بررسی اینکه کل کد یا بخشی ازش یا حتی خطی ازش توسط کیا نوشته و
ویرایش شده
</li>
<li><b class="code">pgp (gpg in openSource World) </b> ساین کردن تگ ها یا کامیت ها
</li>
<h4>--Bisect--</h4>
<li><b class="code">git bisect </b> debuging code by moving through commits
</li>
<ul>
<li><b class="code">git bisect start</b> start using git bisect
</li>
<li><b class="code">git bisect bad <commit code></b>select a bad commit (or just leave it to
select this commit)
</li>
<li><b class="code">git bisect good <commit code></b>select a good commit (or just leave it to
select this commit)
</li>
</ul>
<li><b>Note:</b> You must test your code every time you use bisect then use good or bad after git
bisect !</li>
<!-- start Bisect -->
<section class="part">
<h2 id="Bisect">-Bisect--</h2>
<ul>
<li id="bisect"><b class="code">git bisect:</b> debuging code by moving through commits
</li>
<ul>
<li><b class="code">git bisect start:</b> start using git bisect
</li>
<li><b class="code">git bisect bad:<commit code></b> select a bad commit (or just leave
it to select this commit)
</li>
<li><b class="code">git bisect good:<commit code></b> select a good commit (or just
leave it to select this commit)
</li>
</ul>
<li><b>Note:</b> You must test your code every time you use bisect then use good or bad
after git bisect !</li>
</ul>
</section>
</section>
</div>
</body>
</html>