How to disable git commit -a option

We are a group of developers working with the same set of files. I want to make sure no one is running git commit -a -m or git commit -am

The developers who included me have this bad habit of git commit -am/ -a -m , and we have many machine-specific conf files that are received every time. I could ask us all to use --assume-unchanged, but I want developers to not be able to use the -a flag at all

Is there any way to hack this?

+4
source share
2 answers

I would recommend you solve this problem differently:

  • use a .gitignore file to specifically exclude files that should not be committed, or
  • use pre-commit hook to automatically reject commits that look as if they were made with -a.

When you insist on disabling the -a flag: well, git is open source. Finding and disabling code that reads the -a command-line option and recompiling should not be so difficult. But that would mean that you would have to do it again whenever a new version of git is released, so I would really recommend this.

+5
source

You can write a git script shell that checks if the commit command is set and the -a flag is set. Then you can drop this and pass everything else to the actual git , or call "Bad User! Bad!". Put this script in the path to the actual git path or create an alias for gitwrap .

@PiotrZierhoffer found this:

Example for this: Disable -m in git

+2
source

Source: https://habr.com/ru/post/1436562/


All Articles