-
Notifications
You must be signed in to change notification settings - Fork 0
/
2.github-note.txt
445 lines (305 loc) · 9.85 KB
/
2.github-note.txt
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
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
Github Note
I. Github Terminal Note
0. create new branch which in contain full source in current branch
- git checkout -b "name"
1. switch another brach
- git switch name
2. merge brach b to a
- git branch
--> make sure you are in branch a
- git merge b
--> check code -> accept incomming (code of branch b) or accetp current (code of branch a)
3. git push -u origin master
- -u mean you can type git push for the later
4. remote
- git remote add name "url"
----------------------------------------------
1. git
1.1 How to checkout a remote branch ?
- git fetch
- git checkout branchInRemote
1.2 Pull Target branch then merge to Source Branch - in this case (phase3/s1 - feature/abc)
1.3 See all branch in remote
- git branch -r
1.4 Create branch B from A
- On branch a
- git checkout -b B
- git commit -am "Commit on branch B"
1.5 create new branch C from A
- git checkout -b C A
- git commit -am "Commit on branch C"
1.6 Go back to branch A
- git checkout A
- git commit -am "Commit on branch A"
1.7 Create an octopus merge
- git merge B C
- It look like this
…-o-o-x-------A
|\ /|
| B---/ |
\ /
C---/
1.8 Merge branch B To A
- git checkout A
- git merge B
-----------------
8 .git pull is git fetch && git merge
- if you want to pull A then merge A to B
- git switch A
- git pull origin A
- git switch B
- git merge A
9 delete branch local and remote
delete branch locally
- git branch -d localBranchName
delete branch remotely
- git push origin --delete remoteBranchName
10. change config from win to bash
npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
------
11. git reflog (watch delete commit git)
12. git reset --hard HEAD~1 (delete previous commit & source code)
13. git log (watch log)
-----
14. raw file
https://raw.githubusercontent.com/ducccao/wm-css/master/wm.css
https://.....?raw=true
/************ Github Authentication ****************
15. Github Desktop Login for multiple account problem
git config --global credential.github.com.useHttpPath true
/************ How to change author commit in git ****************
16. How to change author commit in git
git commit --amend --author="Author Name <email@address.com>"
git commit --amend -m "New Commit Message"
17.1 git rebase to a commit hash
git rebase -i 7938d4d5f40bbcfbd72fd739789288c088c91ada
17.2 Rebase turn back to current head
git rebase --continue
git rebase --skip
18. Rebase -i will open VIM, how to undo VIM ?
- press `u`
19. Dropdown the line VIM
- press `i`
20. Turn backto VIM command
- press `esc`
21. Stop at edited file VIM
- :wq (write and save then turn to the #ref rebase)
- :q (quit)
- :qa ()
- :qa!
23. view missing commit details
+ git show ee31819e102432d517ea25a143bda0fbf8103235 --pretty=fuller
24. git cherry pick - pick another branch commit id to current branch
- git cherry-pick b6e7e9e711567527c9c2b35402ef788a5ee451d5
a - b - c - d - e - f -> feat
\
g - h - i -> main
- on main branch
- git cherry-pick c
a - b - c - d - e - f -> feat
\
g - h - i - c -> main
25. How to rename a folder ?
- git mv `old name` `new name`
- mv is stand for move
26. delete multiple branches in locally and remotely
+ locally: git branch -D br1 br2 .. brn
+ remotely: git push -d remote-name br1 br2 .. brn
27. Scenario
on current branch - you changes some files, and you wanted to switch to
another branch and the changed files does not follow on the branch that you switched,
and it's okay if you remove the changed
- current branch: git reset --hard #newest_id
- after that do: git switch another_branch
28. Pull only one branch and not cause merge commit
- git pull --ff-only origin main
29. configure git credential with replace all
git config --global --replace-all user.name "Your New Name"
git config --global --replace-all user.email "Your new email"
git config --global --replace-all user.name "tcvduc"
git config --global --replace-all user.email "caovanducs@gmail.com"
/************ Why we checkout branch ? ****************
+ Prepare push --force case
+ Leader review code
+ CD/CI
/************ Make better branch become main branch ****************
1.
git checkout main
git reset --hard better_brach (rewrite main)
git push --force origin main
----- ----- ----- -----
----- github problem
----- ----- ----- -----
1. repeat readme a lot
----- ----- ----- -----
----- usually use
----- ----- ----- -----
1. set username
git config --global user.name "duccao99"
2. set email
git config --global user.email "caovanducs@gmail.com"
3. show config
git config --list
4. show global config
git config --global --list
5. remove most previous commit
git reset --hard HEAD~1
6. force push
- git push --force
7. github auth
git config --global credential.github.com.useHttpPath true
8. edit the previous commit
- git commit --amend -m "new message"
9. stupid commit ? return to the previous commit but files changed still exists
- git reset --soft head~1
10. show log with one-line & num
- git log -3 --oneline
11. want to update commit date ?
- 1. rebase to the old commit
- 2. git commit --amend --reset-author --no-edit (update command)
- 3. rebase back
- example:
- git rebase -i 8bc4f447f47a653dcb28fc85714cdb931735842d
- edit those commit that wanted to edit (VIM)
- VIM
- press `i` - to change file
- edit
- press `esc` to leave change
- :wq
- git commit --amend --reset-author --no-edit
- git rebase --continue
12. Rebase to the old commit then change author or day or message
- Example
+ git log -3
commit adafae3ea84a2cfdb54d20bfd34044f4da52b199 (HEAD -> main)
Author: duc-trinh-jh <duc.trinh@journeyh.io>
Date: Sun Sep 5 13:20:35 2021 +0700
fb story: update animation function
commit ec24607c2fee9c427aaa0ceca6dc9be34f1d1903
Author: duc-trinh-jh <duc.trinh@journeyh.io>
Date: Sun Sep 5 13:23:11 2021 +0700
update debounce, update pixture
commit 5d24d4ef7fc3826d1d9492accdd34ec3f4827059 (origin/main, origin/HEAD)
Author: duc-trinh-jh <duc.trinh@journeyh.io>
Date: Wed Sep 1 18:31:28 2021 +0700
+ `esc`
+ git rebase -i 5d24d4ef7fc3826d1d9492accdd34ec3f4827059
+ i
edit ec24607c2fee9c427aaa0ceca6dc9be34f1d1903
pick adafae3ea84a2cfdb54d20bfd34044f4da52b199
+ `Esc`
+ :wq
- change author ?
+ git commit --amend --author = "duccao new author"
+ :wq
- Change date ?
+ git commit --amend --date ="Fri, 03 Sep 2021 22:13:13 +0700"
+ :wq
- change message ?
+ git commit --amend -m "new message"
+ :wq
-> If the branch was pushed then commit does not applies in result
-> If the branch was not pushed scenario attempt later
--------------------------------
-- re learn git from the start
--------------------------------
1. git commit -a (--all) -m
- commit all tracked file
2. git commit --amend -m "rewrite the previous commit by --amend"
- rewrite the previous commit
----- Common
1. git config --global credential.github.com.useHttpPath true
2. tcvduc account
git config --global user.name "tcvduc"
Git config
2. set email
git config --global user.email "caovanducs@gmail.com"
---------------------------------
-- repository not found problem
---------------------------------
+ git remote rm origin
+ git remote add origin https://USERNAME:PASSWORD@github.com/username/reponame.git
--> Old way -> not work
+ git remote rm origin
+ git remote add origin https://<tokenhere>@github.com/<user>/<repo>.git
+ Get access token:
Avatar -> settings -> Developer settings -> Personal access tokens
-> generate new token
- example:
git clone https://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@github.com/carparknow/flex.git
- git clone https://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@github.com/duc-trinh-jh/on-board-flex.git
- git clone https://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@github.com/DEV-heyfritz/HeyFritz.git
- new token: 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
git remote add origin https://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@github.com/tcvduc/one-thousand-algorithms.git
git remote set-url origin https://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@github.com/tcvduc/one-thousand-algorithms.git
git remote set-url origin new.git.url/here
30. github recovery code
- scenario:
+ 2FA OTP login need phone app to provide OTP
+ phone broke
-> Recovery code
4eb19-fe14b
ffa23-23618
b65ac-4c623
41a2b-9c293
172ef-a98e8
a4546-dd4b4
fb242-ea9be
803a2-81716
68ae6-3d766
89e0c-561b7
7a174-39059
b3ea5-aaf77
7e671-d5472
1d25a-cad56
fec43-90e5f
983f7-ca559
31. Info
+ Github account
- email: caovanducs@gmail.com
- password: 0908011888Duc
- username: tcvduc
- personal access token: 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
- email: tcvduc.io@gmail.com
- password: 0908011888Duc
- username: tcvduc99
- personal access token: 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
+ npm account
- email: tcvduc.io@gmail.com
- password: \ . X :;123
- username: tcvduc
- repository: git://github.com/my-org/test.git
- email: caovanducs@gmail.com
- password: \ . X :;123
- username: duccao
- xlG4qH8WOep+Kc4p+IvEhR/1Rmk=
32. make the source code back to the old commit
- Example:
- Have
+ commit id: b897b12744
- Do
+ git reset --hard b897b12744
33. watch changes
- git diff
34. jump to another code version
- git log -4
- git checkout a1e8fb5
35. jump to another code version and jump back
- git checkout main
36. change code, and want to get back previous code
- git log -1
- git reset --hard 722dc0fe98cf6adc87596c06c51a26b6ce14b310
37. compare changes between two branches
or two commits
- git diff 722dc0fe98cf6adc87596c06c51a26b6ce14b310
722dc0fe98cf6adc87596c06c51a26b6ce14b312
II. Github Pages - Deploy Static HTML File
- Github Page, deploy static html file, can routing.
- URI:
+ https://tcvduc.github.io/
+ https://tcvduc.github.io/portfolio/1.expanding-cards/solve-3/
- URI structure
+ https://user-name.github.io/folder-name/
+ folder-name/index.html
- folder is a route path
- inside folder has index.html to load into the web page