Question

I often require to do a make clean / make distclean before I do a git add . since I do not want to include binary and other stuffs.

I know I can add some name / pattern in to .gitignore but that's not very productive and flexible. Another solution is to create a bash file but that requires an additional file in my repository that I don't want.

Is there any pre-add configuration that allows me to run script before the actual git add execution ?

Was it helpful?

Solution

The earliest hook Git provides is the pre-commit hook. At this point, git add would already have been run, but you could write a pre-commit hook that ensures certain files / file extensions have not been added. However, this will require the same amount of maintenance as a gitignore file would.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top