Fireship · @fireship

13 Advanced (but useful) Git Techniques and Shortcuts

Uploaded September 7, 2021 · Length 8:07

13 Advanced (but useful) Git Techniques and Shortcuts

Summary

Learn 13 advanced Git techniques and shortcuts to boost your productivity, including aliases, amend flag, stash, and more.

  • git shortcuts
  • git productivity
  • git techniques
  • git aliases
  • git amend flag
  • git stash
  • git bisect
  • git rebase
  • git hooks

Transcript preview

The first 2 minutes of the transcript. Select a timestamp to watch that moment on YouTube.

  1. 0:00

    one of the best pieces of advice i ever

  2. 0:01

    got was get good at git few things are

  3. 0:04

    more scary for a software engineer than

  4. 0:06

    screwing something up with git after

  5. 0:08

    weeks of writing the perfect code you

  6. 0:09

    submit a pull request and end up with a

  7. 0:11

    bunch of embarrassing failed checks and

  8. 0:13

    merge conflicts next thing you know

  9. 0:15

    you're scrambling on stack overflow

  10. 0:16

    looking for a solution that will likely

  11. 0:18

    just add gasoline to the fire git was

  12. 0:20

    created by a guy much smarter than us he

  13. 0:22

    knew if he made it too easy it would

  14. 0:23

    make us weak instead he wanted to give

  15. 0:25

    us the glory of overcoming the challenge

  16. 0:34

    i'm pretty sure that's what he was

  17. 0:35

    thinking in today's video we'll look at

  18. 0:36

    a bunch of different tips and tricks to

  19. 0:38

    make you more productive with git but if

  20. 0:40

    you're new to git i just released a

  21. 0:42

    short course on fire fireship io that's

  22. 0:44

    designed as a modern learning path to

  23. 0:45

    get you started with git and github it

  24. 0:47

    contains a bunch of short videos along

  25. 0:49

    with exercises to transform you into a

  26. 0:51

    professional git user quickly this

  27. 0:53

    content is supported by viewers like you

  28. 0:55

    and i want to send a huge thank you to

  29. 0:57

    everybody out there who's already a pro

  30. 0:58

    member so to get started i'm assuming

  31. 1:01

    you know the basics of git like you know

  32. 1:02

    how to do a git ad followed by a git

  33. 1:04

    commit to save a snapshot of your code

  34. 1:06

    that's usually the first thing you learn

  35. 1:08

    in git but there's actually a better way

  36. 1:10

    to get the job done you can get rid of

  37. 1:11

    the git add and go straight to commit by

  38. 1:14

    using the am flag this will

  39. 1:16

    automatically add all the files in the

  40. 1:18

    current working directory that's a nice

  41. 1:20

    improvement but there's actually an even

  42. 1:21

    more concise way to get the job done

  43. 1:23

    your git config provides a way to create

  44. 1:25

    aliases which are commonly used to

  45. 1:27

    shorten existing commands or create your

  46. 1:29

    own new custom commands for example we

  47. 1:31

    might create an alias called ac that

  48. 1:34

    runs the add and commit command with

  49. 1:35

    just two letters that allows us to get

  50. 1:37

    things done faster but sometimes going

  51. 1:39

    fast leads to mistakes clearly mistakes

  52. 1:42

    were made what if you made a typo on

  53. 1:43

    your last commit message instead of

  54. 1:45

    resetting and creating a new commit the

  55. 1:47

    amend flag followed by a new message

  56. 1:49

    will simply update the latest commit or

  57. 1:51

    maybe you forgot to include or stage a

  58. 1:53

    couple files with your last commit you

  59. 1:55

    can also update the last commit with new

  60. 1:57

    files by using the amend flag and if you

  61. 1:59

    want to keep the same commit message add