Slide 1

Slide 1 text

More than A(dd)C(ommit)P(ull)R(ebase)R(rm) B(ranch)L(og)D(iff)P(ush)C(lone)C(h eckout) Donatas

Slide 2

Slide 2 text

git config % git config --list

Slide 3

Slide 3 text

git config % git config --global push.default current

Slide 4

Slide 4 text

git config % git config --global branch.master.remote origin

Slide 5

Slide 5 text

git config % git config --global remote.origin.fetch +refs/pull/*/head:refs/remotes/pr/* % git checkout pr/123

Slide 6

Slide 6 text

git config % git config --global alias.last 'log -1 HEAD' % git last

Slide 7

Slide 7 text

.gitignore https://www.gitignore.io

Slide 8

Slide 8 text

git clone % git clone git://... -b ‘feature/upgrade_nginx’

Slide 9

Slide 9 text

git clone % git remote add upstream https://… % git fetch --all

Slide 10

Slide 10 text

git checkout % git checkout -b 'feature/upgrade_nginx'

Slide 11

Slide 11 text

git checkout ● Carefully pick the name for a branch (think about others) ● It’s useful to have feature/ or fix/ prefix before

Slide 12

Slide 12 text

git log % git log --oneline

Slide 13

Slide 13 text

git log % git log --grep 'nginx'

Slide 14

Slide 14 text

git log % git log -S 'nginx'

Slide 15

Slide 15 text

git shortlog % git shortlog % git shortlog -s -n --all --no-merges

Slide 16

Slide 16 text

git add % git add .

Slide 17

Slide 17 text

git add % git add

Slide 18

Slide 18 text

git add % git add --interactive

Slide 19

Slide 19 text

git add % git add --patch

Slide 20

Slide 20 text

git rm % git rm --cached

Slide 21

Slide 21 text

git commit % git commit -m (not recommended)

Slide 22

Slide 22 text

git commit % git commit --signoff

Slide 23

Slide 23 text

git commit % git commit --allow-empty

Slide 24

Slide 24 text

git commit % git commit --amend % git push --force

Slide 25

Slide 25 text

git commit % git commit --allow-empty

Slide 26

Slide 26 text

bad commit message example commit a5140910088f33ec6edd3869a1354ebfafb63ff8 Author: joni2back Date: Tue Mar 3 16:58:54 2015 ­0300 fix error

Slide 27

Slide 27 text

good commit message example commit afad5cedf1be827238b376e63b0b93bb555c928e Author: Donatas Abraitis Date: Mon Feb 25 21:16:02 2019 +0200 bgpd: Add peer action for PEER_FLAG_IFPEER_V6ONLY flag peer_flag_modify() will always return BGP_ERR_INVALID_FLAG because the action was not defined for PEER_FLAG_IFPEER_V6ONLY flag. ``` global PEER_FLAG_IFPEER_V6ONLY = 16384; global BGP_ERR_INVALID_FLAG = ­2; probe process("/usr/lib/frr/bgpd").statement("peer_flag_modify@/root/frr/bgpd/bgpd.c:3975") { if ($flag == PEER_FLAG_IFPEER_V6ONLY && $action­>type == 0) printf("action not found for the flag PEER_FLAG_IFPEER_V6ONLY\n"); } probe process("/usr/lib/frr/bgpd").function("peer_flag_modify").return { if ($return == BGP_ERR_INVALID_FLAG) printf("return BGP_ERR_INVALID_FLAG\n"); } ``` produces: action not found for the flag PEER_FLAG_IFPEER_V6ONLY return BGP_ERR_INVALID_FLAG $ vtysh ­c 'conf t' ­c 'router bgp 20' ­c 'neighbor eth1 interface v6only remote­as external' Signed­off­by: Donatas Abraitis

Slide 28

Slide 28 text

git rebase % git rebase --interactive

Slide 29

Slide 29 text

git rebase % git rebase --interactive master

Slide 30

Slide 30 text

git stash % git stash % git stash list % git stash pop

Slide 31

Slide 31 text

git reset % git reset

Slide 32

Slide 32 text

git reset % git reset --hard

Slide 33

Slide 33 text

git reset % git reset --soft HEAD~2

Slide 34

Slide 34 text

git tag % git tag

Slide 35

Slide 35 text

git tag % git tag v2

Slide 36

Slide 36 text

git tag % git tag -a v3

Slide 37

Slide 37 text

git bisect % git bisect start

Slide 38

Slide 38 text

git bisect % git bisect bad

Slide 39

Slide 39 text

git bisect % git bisect good

Slide 40

Slide 40 text

git bisect % git bisect bad % git bisect good

Slide 41

Slide 41 text

git bisect % git bisect reset

Slide 42

Slide 42 text

git bisect % git bisect run

Slide 43

Slide 43 text

git cherry-pick % git cherry-pick

Slide 44

Slide 44 text

git reflog % git reflog

Slide 45

Slide 45 text

git reflog % git reflog show

Slide 46

Slide 46 text

git reflog % git reset refs/remotes/origin/fix/bad_name@{1}