githooks

Git Hook: Take action when a branch is advanced

I'm looking to build and publish a latex document every time I advance the tip of a specific branch. I'm looking at what hook I should be putting my build script and which conditions I need to check for. ...

change default git hooks

Not sure if this is possible in git (I haven't found it but I may be using the wrong vocabulary in my searches), but it be would useful to be able to modify and enable hooks as the defaults for all new repositories (at the time of creation I mean) so these don't have to be customized each time a new repository is created. It seems the e...

Git post-receive - how to check if pushed branch is merged with master

Hi In our team we are usually pushing all tasks into separate branches, and after that release-manager review those branches and merge them into 'master' branch Sometimes team-members forget to merge their branches with master branch(before pushing) - so what I'm trying to do is - output a message "Please merge with master" after user ...

Dissallow deletion of Master branch in git

I'm trying to setup a git hook that will disallow anyone to delete the master, alpha, and beta branches of our repository. Can anyone help with this? I have never done a git hook so i don't want to try my luck in developing my own without a little help. Thanks in advance. ...

Have remote git repository refuse merge commits on push

What I want to do: I want to disallow any merge commits to be pushed to the central repository. The only exception being if the merge is between branches that exist in the central repository. I want to enforce this at the central repository. Explanation of why I want to do this: Note: If this explanation throws you off the trail of ...

Git hooks management

We use custom-written Git hooks in our project. Hooks are stored in a project's repository, and, when they do change, to get a new version each user must copy them manually in his .git/hooks directory. This is rather inconvenient. One way to improve this is to make .git/hooks a symlink into worktree. But this would imply that each bra...

Using the pre-commit hook to clean code

Is it good form to scrub development code from my source files during a pre-commit hook? For example, I have code that is calling xdebug_break() and I want to remove the calls to that function from any files that have it before committing my code to the repository. I would rather not check for the function before calling it because I ...

Commit in git only if tests pass

I've recently started using git, and also begun unit testing (using Python's unittest module). I'd like to run my tests each time I commit, and only commit if they pass. I'm guessing I need to use pre-commit in /hooks, and I've managed to make it run the tests, but I can't seem to find a way to stop the commit if they tests fail. I'm ru...

Git commit hooks - global settings

I've written a Git post-commit hook and it works correctly. However, I want to add this hook to apply to all current (and future) git repositories I am working on. I tried adding the hook to my ~/.git/hooks/ instead of in the hooks directory in the project directory, however, this did not seem to work. Is there any way to create globa...

is there a hack for fully functional cross-platform shebang line?

Problem: apparently the scripts in the .git/hooks directory depend on the filename matching one of: post-commit pre-commit pre-rebase etc ... No concept of "file extension" is required because the "shebang line" indicates how the file should run, as long as it is executable and running on your Linux box. The problem is when you have...

Git post-receive hook not working

We're using git with a central repo (using Gitosis). I've created a post-receive hook to generate an email to the dev mailing list whenever changes are pushed to the central repo, and to generate documentation from the documentation folder in the git repo. Therefore, in ~git/ I've got a directory, we'll call it 'a' that contains a clone...

How do I hook a git pull on the remote?

Is there a way to hook when a git pull happens on the remote (similar to a pre-receive or post-receive). Basically I'd like to be able to cause the remote to commit whatever it has when there is a pull. In my situation, whatever is live on the remote is an authoritative source which may get modified without a git commit. I want to mak...

pre-push git hook?

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? ...

git init template, replacing modified hooks

I am constantly updating my local git hooks. I have a repo to house my .git template. This means that I am constantly running git init --template=../git-template to update repos with my hook changes. Problem: Everytime I run git init --temp..., I need to first remove the hooks in .git/hooks that will be replaced with the updated hooks. ...

git: repo monitoring tool

Do you know any good repo monitoring solution? I'd like to get information when someone pushes to remote repo (preferably via taskbar tray icon: "someuser pushed…"). Other solutions I consider: recieve hook periodically git log via cron check for updates on running every git command (my system of choice is Ubuntu) ...

Telling rspec to not load files

I'm trying to add some commit hooks to my git repo. I want to leverage Rspec and create commit message specs that will run each time I commit. I have figured out how to run rspec outside of the 'spec' command, but I now have an interesting problem. Here is my current code: .git/hooks/commit-msg #!/usr/bin/env ruby require 'rubygems' ...

git-commit-notifier with gmail

First of all you have to know I'm total Ruby noob :) I installed git-commit-notifier (http://github.com/ilozka/git-commit-notifier) on my system (Ubuntu 10.04) and followed all the installation instructions but every time I push to my git repository I get this error message: remote: Sending mail... remote: /usr/lib/ruby/1.8/net/smtp.r...

Can a Git hook automatically add files to the commit?

I'd like to add an automatically generated file to the same commit using a pre- or post-commit hook in Git, dependent on the files that were modified in that commit. How would I go about this? I've tried this as a pre-commit hook, but no luck: #!/bin/sh files=`git diff --cached --name-status` re="<files of importance>" if [[ $files =~...

Writing Git hooks in python/bash scripts

I have recently needed to write git hooks, for all commits to reference a particular ticket. I was hoping for a place to start learning. All the stuff in the pro git book is written in Ruby. Since Ruby is not my strong suit, can anybody share tutorials about git hooks written in other languages? (I'd particularly prefer Python or Bash s...

Git hook to disallow directory creation in top level

Any better way to prevent stop top level directory creation by users may be while on push or direct file creation Thanks in Advance Dhandu ...