4

I would like to run a compression script before git push such that anytime a user tries to push changes to a remote repository, it checks for uncommitted changes in the compressible assets, aborts git push, runs git commit, then runs git push again.

Is something like that possible using only git hooks?

Cascabel
  • 479,068
  • 72
  • 370
  • 318
Lance
  • 75,200
  • 93
  • 289
  • 503

2 Answers2

5

Git is getting a pre-push hook in the 1.8.2 release.

Sample pre-push script: https://github.com/git/git/blob/87c86dd14abe8db7d00b0df5661ef8cf147a72a3/templates/hooks--pre-push.sample

1.8.2 draft release notes talking about the new pre-push hook: https://github.com/git/git/blob/master/Documentation/RelNotes/1.8.2.txt

manojlds
  • 290,304
  • 63
  • 469
  • 417
  • But does that allow doing commits? The OP asked for a way to do commits and then restart the push; how to do that? – Carlo Wood Jan 12 '20 at 11:12
3

Take a look at this patch.

See .git/hooks/ in your repo for sample hooks, maybe you will see some alternative.

takeshin
  • 49,108
  • 32
  • 120
  • 164