How to restrict push size in Git

I have gitolite-admin.

Some times our programmers don't use .gitignore file and commit whole directory to the remote repo.

How can I restrict push size in git?

I tried search in git config but unsuccessfully.

Upvotes: 0

Views: 461

Answers (2)

Olga Pshenichnikova
Olga Pshenichnikova

Reputation: 1581

You can limit by changed files amount. In your config file:

repo @all
    -   VREF/COUNT/50   = @all

Upvotes: 1

CodeWizard
CodeWizard

Reputation: 142402

It has nothing to do with git commit.
You need to set up hooks for this job.

What are some more forceful ways than a .gitignore to keep (force) files out of a repo?

Your hook will check what you want to do and then will decide if to approve the push or not.

In your hook you will have something like this:

# in the hook use this line to get the size of each file
git ls-tree -l

enter image description here

If you want to see the same results in your repository use this:

git ls-tree HEAD -l

How to write hooks:

Here is a nice sample how to attrack attention in hooks:
How to enforce a git commit message policy on local system to prevent pushing

Upvotes: 1

Related Questions