git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Feature idea: Git hook for pre-checkout

From
MWMike Weltevrede <mikeweltevrede@gmail.com>
Date
Jan 29, 2025, 10:49 UTC
Message-ID
<CAAE-bwUQ+0ERbvC=SS=-R_K4H3p2su+=Ogf7BSkyq5J4GmmRYw@mail.gmail.com>
Good morning,

I had an idea for a feature in Git. I am not sure if this is the correct channel, but I could not find anything else. If not, could you please let me know the best way to submit this?

Below, I will explain the idea and then the problem that this would solve.

<The idea> I have a project that is using Git hooks. Besides pre-commit and pre-push, I would like to use pre-checkout (rather than the already available post-checkout). However, it seems like an active choice not to have pre-checkout given the existing hooks, so I am curious as to the reason behind this.

<The problem> I want to do branch name validation when someone does git checkout -b. If the branch name does not meet the requirements, the user should not be allowed to checkout to it. As such, the post-checkout hook does not fully meet my needs. It helps with doing the branch name validation, but if it fails, the user is still on the feature branch. As such, if they are ignorant about the error message, this does not stop them. I am currently combining post-checkout and pre-push but would prefer pre-checkout because this would prevent the user from doing work on this feature branch and having to move their work.

I am looking forward to your thoughts. Thank you for your consideration.
Met vriendelijke groet / Kind regards,
Mike Weltevrede
Next: brian m. carlson
Message 1 of 5 in “Feature idea: Git hook for pre-checkout”
  1. Mike WeltevredeJan 29, 2025
  2. brian m. carlsonJan 30, 2025
  3. Konstantin KhomoutovJan 30, 2025
  4. Junio C HamanoJan 30, 2025
  5. Mike WeltevredeFeb 1, 2025

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.