Complete guide to GitHooks - Creating your own pre-commit hooks

แชร์
ฝัง
  • เผยแพร่เมื่อ 9 พ.ค. 2023
  • GitHooks are a great way of automating tasks and checking information while using git. These hooks are both powerful surprisingly easy to create yourself. In this video tutorial we run through how git hooks work and how to create both local and global git hooks which can call an API, use grep to find keys and even call other local tools.
    Links:
    GgShield: github.com/GitGuardian/ggshield
    Learn more at
    pre-commit framework: pre-commit.com/
    Git Hooks.com githooks.com
  • วิทยาศาสตร์และเทคโนโลยี

ความคิดเห็น • 23

  • @mistymu8154
    @mistymu8154 9 หลายเดือนก่อน +12

    Great video. Just a quick aside, by default, VS Code hides the .git folder so needed to add the following to my settings:
    "files.exclude": {
    "**/.git": false
    }

  • @MrUmban
    @MrUmban 4 หลายเดือนก่อน

    Amazing explanation. Thank you!

  • @jaysharma3504
    @jaysharma3504 10 หลายเดือนก่อน +2

    Great video dude! Do post on pre-commit framework when you can. Looking forward to it!

    • @GitGuardian
      @GitGuardian  3 หลายเดือนก่อน

      Working on the new video now!

  • @bactran7799
    @bactran7799 9 หลายเดือนก่อน +1

    your video is really valuable to me. Thanks a lot

  • @mirosawkodzinski9779
    @mirosawkodzinski9779 9 หลายเดือนก่อน +1

    Great tutorial., explains a lot.

  • @raypenha2572
    @raypenha2572 ปีที่แล้ว

    Congratulations for the vídeo

  • @sanjayaelvitigala3086
    @sanjayaelvitigala3086 6 หลายเดือนก่อน +1

    nicely explained.

    • @GitGuardian
      @GitGuardian  6 หลายเดือนก่อน

      Thanks for y7our feedback

  • @clusterdriven
    @clusterdriven 6 หลายเดือนก่อน +1

    Great video. Thank you for this. Me personally, I prefer the approach of creating a wrapper for git, so that i can say:
    commit "message here"
    and it automatically adds everything + does any other checks such as linting or tests before commits. This also provides the benefit of a syntax that fits your needs. But thank you for the content

    • @GitGuardian
      @GitGuardian  6 หลายเดือนก่อน

      Another good option, perhaps a little more advanced than a git hook. Maybe worth a vedio on this method

    • @clusterdriven
      @clusterdriven 6 หลายเดือนก่อน

      @@GitGuardian Right. It does not need to be super advanced. In my case, for example, I simply add this to my .bashrc:
      # Automatically stage all, commit, and push in one command
      function commit() {
      if [ -z "$1" ]; then
      echo "Please provide a commit message."
      return 1
      fi
      git add .
      git commit -m "$1"
      push
      }
      the above automatically adds all changes to staging, commits with a given message, and pushes. Of course you can customize it to your needs. But the above is a simple bash function.

    • @clusterdriven
      @clusterdriven 6 หลายเดือนก่อน

      the "push" is because I also have the following alias:
      # Using push will resolve to git push origin $(current_branch)
      function push() {
      git push origin $(git symbolic-ref --short HEAD)
      }

  • @kamyarghanbarpour764
    @kamyarghanbarpour764 23 วันที่ผ่านมา +1

    Thanks a lot

    • @GitGuardian
      @GitGuardian  19 วันที่ผ่านมา

      Most welcome

  • @roboman3418
    @roboman3418 3 หลายเดือนก่อน

    thanks!

  • @test-em3re
    @test-em3re หลายเดือนก่อน

    will this work on GitHub desktop ?

  • @eswarm1234
    @eswarm1234 3 หลายเดือนก่อน

    Please do a video on pre-commit framework

    • @GitGuardian
      @GitGuardian  3 หลายเดือนก่อน

      Sure thing @eswarm1234

  • @larsvagt1340
    @larsvagt1340 2 หลายเดือนก่อน

    Basically cool explanation. Unfortunately I cannot give to my dev team due to the joke. One of the devs is a dad who experience a similar thing at school and it would really hurt him. :(

  • @anshuldishoriya2992
    @anshuldishoriya2992 2 หลายเดือนก่อน +1

    nicely explained.

    • @GitGuardian
      @GitGuardian  19 วันที่ผ่านมา

      Thanks for liking