GithubHelp home page GithubHelp logo

easwy / git-reject-binaries-and-large-files Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pattivacek/git-reject-binaries-and-large-files

0.0 0.0 0.0 7 KB

A git pre-receive hook to reject binaries and large files.

License: MIT License

Shell 100.00%

git-reject-binaries-and-large-files's Introduction

git-reject-binaries-and-large-files

A git pre-receive hook to reject binaries and large files. Also, a pre-commit hook for rejecting merge markers.

pre-receive hook

This hook prevents users from committing binary files and files greater than 1MB. This can be easily altered, or either restriction can be disabled. To override the restrictions, add 'override restrictions' to the commit message corresponding to the problematic files.

This hook must be installed server-side in the hooks subdirectory. It is only triggered when a user pushes to the server. Committing locally will not be affected. This means that if a commit is made with a binary, the user won't notice the problem until they try to push to the server. To fix the problem, the user will have to make judicious use of git rebase -i to remove the commit, edit it to remove the problematic files, or edit the message to add the override text.

For use with gitolite, the hook must be installed in the repo-specific local code directory known to the git user and the gitolite system. See here:
http://gitolite.com/gitolite/non-core.html#rsh

The pre-receive hook, which was originally called 'check-binary', is based off of two other pre-receive hooks found on github:
https://github.com/avar/pre-receive-reject-binaries
https://github.com/amacneil/git-banish-large-files

However, because pre-receive hooks cannot be chained (you can only have one at a time), I wrote my own to combine the features I wanted from both of the above hooks.

pre-commit hook

I've also included a bonus pre-commit hook for preventing merge markers (<<<<<<<, >>>>>>>, =======) from being left in a commit. It's careful enough to only check for those symbols at the start of a line, with the exact count, followed by a space or newline. This could also be included in the pre-receive hook as well, but I haven't had a need to do that yet.

Installation with pre-commit

Copy the pre-commit script in this repo to a file called reject_merge_markers.sh and add it to the project's .pre-commit-confic.yaml:

  - id: reject_merge_markers
    name: "Reject merge markers"
    language: "script"
    entry: tools/reject_merge_markers.sh

git-reject-binaries-and-large-files's People

Contributors

pattivacek avatar andyhasit avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.