Slide 1

Slide 1 text

Mouson (陳佑 竹 ) 2025.04.19 台 日 技術交流聚會@ 言文 字 10 Command You Should Start Using Today

Slide 2

Slide 2 text

About Me • Mouson (陳佑 竹 ) • GitLab Hero • Senior System Analyst • GitLab Taipei User Group / DevOps Taiwan / Laravel Taiwan • [email protected] • https://gitlab.com/mo-playground • https://gitlab.com/mouson

Slide 3

Slide 3 text

is 20 Years Old https://github.com/git/git/commit/e83c5163316f89bfbde7d9ab23ca2e25604af290

Slide 4

Slide 4 text

Some Command You Should Using Today 01 02 03 04 05 06 07 08 09 10

Slide 5

Slide 5 text

Switch to a speci fi ed branch. switch Ref: https://git-scm.com/docs/git-switch 01 02 03 04 05 06 07 08 09 10 v2.23

Slide 6

Slide 6 text

Restore speci fi ed paths in the working tree with some contents from a restore source. restore Ref: https://git-scm.com/docs/git-restore 01 02 03 04 05 06 07 08 09 10 v2.23

Slide 7

Slide 7 text

Save your local modi fi cations to a new stash with messages stash push -m Ref: https://git-scm.com/docs/git-stash v2.13 01 02 03 04 05 06 07 08 09 10

Slide 8

Slide 8 text

-r, --rebase-merges By default, a rebase will simply drop merge commits from the todo list, and put the rebased commits into a single, linear branch. With --rebase-merges, the rebase will instead try to preserve the branching structure within the commits that are to be rebased, by recreating the merge commits. rebase -r Ref: https://git-scm.com/docs/git-rebase 01 02 03 04 05 06 07 08 09 10

Slide 9

Slide 9 text

rebase -r Ref: https://git-scm.com/docs/git-rebase 01 02 03 04 05 06 07 08 09 10 A B C D E F G H I J git rebase D git rebase D -r

Slide 10

Slide 10 text

rebase -r Ref: https://git-scm.com/docs/git-rebase 01 02 03 04 05 06 07 08 09 10 A B C D E F G H I J git rebase D git rebase D -r A B C D E' F' G' H' I' J'

Slide 11

Slide 11 text

rebase -r Ref: https://git-scm.com/docs/git-rebase 01 02 03 04 05 06 07 08 09 10 A B C D E F G H I J git rebase D git rebase D -r A B C D E' F' G' H' I' J' A B C D E' F' G' H' I' J'

Slide 12

Slide 12 text

Reuse recorded resolution of con fl icted merges rerere https://git-scm.com/docs/git-rerere 01 02 03 04 05 06 07 08 09 10 v1.5.3

Slide 13

Slide 13 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!!

Slide 14

Slide 14 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!! I have a Apple Pen !!!

Slide 15

Slide 15 text

GIT Rerere Demo 1. enable rerere feature git con fi g --global rerere.enabled true https://goo.gl/8wj1he

Slide 16

Slide 16 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!!

Slide 17

Slide 17 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!!

Slide 18

Slide 18 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!!

Slide 19

Slide 19 text

Local GIT Rerere Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!!

Slide 20

Slide 20 text

Manage multiple working trees attached to the same repository. worktree https://git-scm.com/docs/git-worktree 01 02 03 04 05 06 07 08 09 10 v2.5

Slide 21

Slide 21 text

Local GIT worktree Sample I have a World!!! feature master I have a Apple !!! I have a Pen !!! 01 02 03 04 05 06 07 08 09 10

Slide 22

Slide 22 text

Reduce your working tree to a subset of tracked fi les. sparse-checkout 01 02 03 04 05 06 07 08 09 10 https://git-scm.com/docs/git-sparse-checkout

Slide 23

Slide 23 text

Use binary search to fi nd the commit that introduced a bug bisect Ref: https://git-scm.com/docs/git-bisect v1.5 01 02 03 04 05 06 07 08 09 10

Slide 24

Slide 24 text

v2.3

Slide 25

Slide 25 text

? ? ? ? ? ? ? HEAD Some feature was a failure after merge v2.3

Slide 26

Slide 26 text

? ? ? ? ? ? ? HEAD Some feature was a failure after merge v2.3 git bisect start HEAD v2.3

Slide 27

Slide 27 text

Use git bisect search failure commit v2.3 ? ? ? ? ? ? ? HEAD git bisect start HEAD v2.3

Slide 28

Slide 28 text

Use git bisect search failure commit v2.3 ? ? ? ? ? ? ? HEAD git bisect start HEAD v2.3

Slide 29

Slide 29 text

Use git bisect search failure commit v2.3 ? ? ? ? ? ? ? HEAD BAD git bisect start HEAD v2.3

Slide 30

Slide 30 text

Use git bisect search failure commit v2.3 ? ? ? ? ? ? ? HEAD BAD

Slide 31

Slide 31 text

Use git bisect search failure commit v2.3 ? ? ? ? ? ? ? HEAD BAD git bisect bad

Slide 32

Slide 32 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD git bisect bad

Slide 33

Slide 33 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD git bisect bad

Slide 34

Slide 34 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD

Slide 35

Slide 35 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD

Slide 36

Slide 36 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD

Slide 37

Slide 37 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD git bisect good

Slide 38

Slide 38 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD git bisect good

Slide 39

Slide 39 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD GOOD git bisect good

Slide 40

Slide 40 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD GOOD

Slide 41

Slide 41 text

Use git bisect search failure commit v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD GOOD X

Slide 42

Slide 42 text

use git blame fi nd detail v2.3 ? ? ? BAD ? ? ? HEAD BAD BAD BAD GOOD GOOD X

Slide 43

Slide 43 text

Print lines matching a pattern grep https://git-scm.com/docs/git-grep 01 02 03 04 05 06 07 08 09 10 v0.99.4

Slide 44

Slide 44 text

Run tasks to optimize Git repository data gc, commit-graph, loose-objects... maintenance https://git-scm.com/docs/git-maintenance 01 02 03 04 05 06 07 08 09 10 v2.29

Slide 45

Slide 45 text

Q & A 陳佑 竹 Mouson https://facebook.com/mouson