Tag: githooks

Git hooks environment variables missing

I am creating a custom build system for my node app on Digital Ocean which involves git hooks to install dependencies and start the app. Part of the app config reads sensitive data (which cannot be checked into the repo) from environment variables. In my git hook I stop the app using an external script, […]

Why can't git post-receive hook find single file in repo?

I have this git post-receive hook #!/bin/sh git –work-tree=/var/www/myproject –git-dir=/home/git/myrepo.git checkout -f — api.py And the local repo simply contains a .git folder and a api.py file. When I push the project I get the following error: $ git push Counting objects: 3, done. Delta compression using up to 4 threads. Compressing objects: 100% (2/2), […]

How to assign different git per-folder permissions while you maintain the commit binding?

Background I’ve searched a lot and I am aware that different folder permissions under the same repository is something that is not supported by git. However, I still haven’t found a satisfactory git model for my infrastructure although I’ve studied both submodules and subtree References Why are git submodules incompatible with svn externals? Using two […]

Curl Initialization error with git pre-push hook

I created a git pre-push hook to check the commits being pushed. One of the validation steps fetches some data using cURL for validating the commit. On running git push, cURL fails to initialize with error curl: (2) Failed initialization The pre-push hook has the correct permissions (-rwx——). To narrow down the problem I removed […]

Writing a pre-push hook in Git to grep all files for regex want to reject push if regex not found

I have the following pre-push hook. Ideally I would like it to go through all files that are being pushed to my repository and reject the push if the content of any of the files doesn’t match the regular expression defined at the top. I’m getting the following error when attempting to loop through the […]

Git automatic merge through branches

I am trying to implement a hook that automatically merges through some branches that we currently have. Let’s say we have 4 branches: project-1.0, project-1.1, project-1.2, master. The goal is, that if we have to fix an issue at some at let’s say project-1.0 that change to automatically propagate to the rest of the branches. […]

How to have git disregard unstaged changes on a post/pre-commit hook

I am trying to do the commit should pass all tests to succeed automation in my rails project. The problem is that I use git add –patch quite a lot before I commit and I want my tests to only run on the staged changes. Solution 1: do a git stash –keep-index on the pre-commit […]

git pre-commit code modifications are applied after commit instead before

I wrote a pre-commit hook to increment the version number in the source. Why are the changes applied after the commit? What can I do to do that prior to the commit? #!/bin/sh # Hook to increment version number before checkin REPO_DIR=$(cd `dirname $0`/../.. && pwd) VERS_FILE=”${REPO_DIR}/version.php” CUR_DATE=`date -u ‘+%Y-%m-%d %H:%M:%S’` HOOK=`basename $0` if [ […]

Per-branch, per-repo commit hook in gitolite

I want to add a commit hook that works when a push is received on a gitolite/git server for a given branch and repo combination only (branch ‘cat’ on repo ‘dog’). My environment: git version, What I have done so far: Touched a file at /home/git/repositories/dog.git/hooks/post-receive.secondary on the git/gitolite server. Edited the file with […]

Git deployment with post-receive hook

I want to develop my websites per git, but I have some sort of chicken and egg problem. There is one server with an git –bare repository (the main repo; /var/dev.git) one clone for the doc-root (var/www) of the apache webserver and for each user one local repository. Ok, this works really nice, but now […]

Git Baby is a git and github fan, let's start git clone.