Upgrade to Pro — share decks privately, control downloads, hide ads and more …

git in operations

C93cedd1db0f5282ef78171df9c940ed?s=47 Donatas
April 26, 2019

git in operations

C93cedd1db0f5282ef78171df9c940ed?s=128

Donatas

April 26, 2019
Tweet

Transcript

  1. 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

  2. git config % git config --list

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

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

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

    checkout pr/123
  6. git config % git config --global alias.last 'log -1 HEAD'

    % git last
  7. .gitignore https://www.gitignore.io

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

  9. git clone % git remote add upstream https://… % git

    fetch --all
  10. git checkout % git checkout -b 'feature/upgrade_nginx'

  11. git checkout • Carefully pick the name for a branch

    (think about others) • It’s useful to have feature/ or fix/ prefix before
  12. git log % git log --oneline

  13. git log % git log --grep 'nginx'

  14. git log % git log -S 'nginx'

  15. git shortlog % git shortlog % git shortlog -s -n

    --all --no-merges
  16. git add % git add .

  17. git add % git add <path>

  18. git add % git add --interactive

  19. git add % git add --patch

  20. git rm % git rm --cached <path>

  21. git commit % git commit -m (not recommended)

  22. git commit % git commit --signoff

  23. git commit % git commit --allow-empty

  24. git commit % git commit --amend % git push --force

  25. git commit % git commit --allow-empty

  26. bad commit message example commit a5140910088f33ec6edd3869a1354ebfafb63ff8 Author: joni2back <joni2back@gmail.com> Date:

    Tue Mar 3 16:58:54 2015 ­0300 fix error
  27. good commit message example commit afad5cedf1be827238b376e63b0b93bb555c928e Author: Donatas Abraitis <donatas.abraitis@gmail.com>

    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 <donatas.abraitis@gmail.com>
  28. git rebase % git rebase --interactive <commit>

  29. git rebase % git rebase --interactive master

  30. git stash % git stash % git stash list %

    git stash pop
  31. git reset % git reset <commit>

  32. git reset % git reset --hard <commit>

  33. git reset % git reset --soft HEAD~2

  34. git tag % git tag

  35. git tag % git tag v2

  36. git tag % git tag -a v3

  37. git bisect % git bisect start

  38. git bisect % git bisect bad <commit>

  39. git bisect % git bisect good <commit>

  40. git bisect % git bisect bad % git bisect good

  41. git bisect % git bisect reset

  42. git bisect % git bisect run <cmd>

  43. git cherry-pick % git cherry-pick <commit>

  44. git reflog % git reflog

  45. git reflog % git reflog show <branch>

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