* about git hooks @ 2020-10-17 14:24 Sri Harsha Akavaramu 2020-10-17 20:38 ` brian m. carlson 0 siblings, 1 reply; 3+ messages in thread From: Sri Harsha Akavaramu @ 2020-10-17 14:24 UTC (permalink / raw) To: git Hi git, I just wanted to know something about git hooks. we use GitHub enterprise and I'm the owner of the GitHub. I'm trying to understand that I want to pose the pre-commit and post-commit rules on all the developers by default and is there a way to pose git hook restrictions on all developers on default. I came to know when reading with the documentation we cant push hooks to source control. Then what is the best preferred way to pose pre-commit things on all developers using the repository? Thank you, Sri Harsha ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: about git hooks 2020-10-17 14:24 about git hooks Sri Harsha Akavaramu @ 2020-10-17 20:38 ` brian m. carlson 2020-10-20 10:48 ` Sri Harsha Akavaram 0 siblings, 1 reply; 3+ messages in thread From: brian m. carlson @ 2020-10-17 20:38 UTC (permalink / raw) To: Sri Harsha Akavaramu; +Cc: git [-- Attachment #1: Type: text/plain, Size: 2200 bytes --] On 2020-10-17 at 14:24:10, Sri Harsha Akavaramu wrote: > Hi git, Hey, > I just wanted to know something about git hooks. > > we use GitHub enterprise and I'm the owner of the GitHub. > I'm trying to understand that I want to pose the pre-commit and > post-commit rules on all the developers by default and is there a way > to pose git hook restrictions on all developers on default. > > I came to know when reading with the documentation we cant push hooks > to source control. Then what is the best preferred way to pose > pre-commit things on all developers using the repository? This is a great question, and it's kind of answered in our FAQ[0]. The short answer is that you don't. It's possible for any user to simply bypass pre-commit hooks with --no-verify without being noticed, and there are a lot of good reasons to do so. For example, if I need to make a large set of changes, I may make a large number of temporary commits, one each time I make a change that works. Those commits won't meet anybody's set of standards and therefore won't pass the hook, and I'll need to clean them up later, but that helps me organize my development process in a useful way. The hook here would just be an annoyance that gets in the way. You may wish to provide hooks and an install script for the benefit of the user who wants them, but anything that runs on a developer system cannot be an effective control. The right way to add checks that need to apply to all users is to use either a pre-receive hook or a CI system, plus code review. That lets your tooling verify things like commit message formatting, code formatting, tests, and other things you'll want to check before merge. The code review, besides being a best practice for finding bugs and problems before merge, also prevents developers from neutering the CI system by disabling it from working properly. That's the way that most organizations handle these problems, and generally it works pretty well. [0] https://git-scm.com/docs/gitfaq#Documentation/gitfaq.txt-HowdoIusehookstopreventusersfrommakingcertainchanges -- brian m. carlson (he/him or they/them) Houston, Texas, US [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 263 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: about git hooks 2020-10-17 20:38 ` brian m. carlson @ 2020-10-20 10:48 ` Sri Harsha Akavaram 0 siblings, 0 replies; 3+ messages in thread From: Sri Harsha Akavaram @ 2020-10-20 10:48 UTC (permalink / raw) To: brian m. carlson, Sri Harsha Akavaramu, git Awesome, thanks! for your reply On Sun, Oct 18, 2020 at 2:08 AM brian m. carlson <sandals@crustytoothpaste.net> wrote: > > On 2020-10-17 at 14:24:10, Sri Harsha Akavaramu wrote: > > Hi git, > > Hey, > > > I just wanted to know something about git hooks. > > > > we use GitHub enterprise and I'm the owner of the GitHub. > > I'm trying to understand that I want to pose the pre-commit and > > post-commit rules on all the developers by default and is there a way > > to pose git hook restrictions on all developers on default. > > > > I came to know when reading with the documentation we cant push hooks > > to source control. Then what is the best preferred way to pose > > pre-commit things on all developers using the repository? > > This is a great question, and it's kind of answered in our FAQ[0]. The > short answer is that you don't. > > It's possible for any user to simply bypass pre-commit hooks with > --no-verify without being noticed, and there are a lot of good reasons > to do so. For example, if I need to make a large set of changes, I may > make a large number of temporary commits, one each time I make a change > that works. Those commits won't meet anybody's set of standards and > therefore won't pass the hook, and I'll need to clean them up later, but > that helps me organize my development process in a useful way. The hook > here would just be an annoyance that gets in the way. > > You may wish to provide hooks and an install script for the benefit of > the user who wants them, but anything that runs on a developer system > cannot be an effective control. > > The right way to add checks that need to apply to all users is to use > either a pre-receive hook or a CI system, plus code review. That lets > your tooling verify things like commit message formatting, code > formatting, tests, and other things you'll want to check before merge. > The code review, besides being a best practice for finding bugs and > problems before merge, also prevents developers from neutering the CI > system by disabling it from working properly. > > That's the way that most organizations handle these problems, and > generally it works pretty well. > > [0] https://git-scm.com/docs/gitfaq#Documentation/gitfaq.txt-HowdoIusehookstopreventusersfrommakingcertainchanges > -- > brian m. carlson (he/him or they/them) > Houston, Texas, US -- With Regards, SriHarsha Akavaramu, +919493841589. ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-10-20 10:48 UTC | newest] Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 2020-10-17 14:24 about git hooks Sri Harsha Akavaramu 2020-10-17 20:38 ` brian m. carlson 2020-10-20 10:48 ` Sri Harsha Akavaram
Code repositories for project(s) associated with this public inbox https://80x24.org/mirrors/git.git This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).