2

I checked git help hooks and either it is impossible or I missed this.

I want this rather than pre-commit as program in repository generates files, as result my current workflow is

git add -A ruby script_stored_in_repository_that_generates_something.rb <checking generated work that is not tracked in the repository> git commit -m "what was changed"

and I want to eliminate manual script run as pointless.

I know I can use pre-commit hook, but I prefer to edit work while code is staged rather than reverting/undoing/amending commits.

reducing activity
  • 1,985
  • 2
  • 36
  • 64

1 Answers1

2

Unfortunately I don't think that exists. I think the closest you can come is to make an alias. You can't override git commands with alias so you must use a different name than 'add'.

git config alias.ad '!./my_script.sh && git add'
crea1
  • 11,077
  • 3
  • 36
  • 46
  • "You can't override git commands with alias so you must use a different name than 'add'." It is aliased already, so that it is not a problem. Now I need to figure out how to make this alias so for repositories without this file the script will not be run. – reducing activity May 24 '17 at 08:20
  • You could perhaps look into conditional includes and only have the alias defined for a specific folder https://stackoverflow.com/questions/8801729/is-it-possible-to-have-different-git-config-for-different-projects/43884702#43884702 @MateuszKonieczny – crea1 May 24 '17 at 08:25