FAQ Database Discussion Community


Git: pre-receive hook to allow only merges and not direct commits into master

git,git-merge,githooks,git-commit
I have a problem creating a pre-receive hook on a git remote branch, doing what I want. What's the problem? Direct commits to the master branch should be not allowed. Only merges into the master branch should be allowed. Solution My solution until now is to check, if there are...

Stop git commit in pre-commit hook with exit

osx,git,bash,githooks,pre-commit-hook
I'm trying to stop a git commit from continuing with a pre-commit hook. From reading the manual, it should stop when you return an exit code other than 0. I'm testing to see if the csscomb command returns an error, and if it does then break the loop and exit,...

Local Git Hook Pre-Commit/Pre-Push does not run (Windows)

git,powershell,github,githooks,pre-commit-hook
I have a repo set up which is supposed to run a fairly simple pre-push/pre-commit powershell script (It doesn't really matter when the script executes). However, for the life of me I cannot get it to run. I have tried to use chmod +x .git/hooks/* and chmod ug+x .git/hooks/* I...

Git post-receive hook is not executed

linux,git,githooks,git-post-receive
The following post-receive hook: #!/bin/bash echo "-> Post-receive test" is not executed when pushing to my remote repository. The remote is ssh://[email protected]:2222/home/git/repo.git (it's a VM) and works, as when I manually checkout it I see the modifications I've made. Some additional informations ... $ ls -al /home/git drwxr-xr-x 7 git...

“Arguments to path.resolve must be strings” when calling 'gitbook build' from a Git hook

node.js,git,gruntjs,githooks,gitbook
I am trying to run gitbook build within a post-receive Git hook on my (Gitlab, Debian 7, virtual private) server. Basically I want to: checkout the bare repository to a temporary dir run gitbook build in that temporary dir sync with the webspace through rsync The post-receive script runs something...

How to git-diff a file against “theirs” version after resolving conflicts

git,git-merge,githooks,git-diff,pre-commit-hook
In a pre-commit hook, I want to make sure that nobody (except 1 person) is able to change restricted_file.txt The hook needs to handle the case when someone performs 'git pull' or 'git merge some_branch', obtains the latest restricted_file.txt but something_else.txt causes a conflict. He resolves the conflict and keep...

git diff not working on a bare repo, post-receive hook

git,gitlab,githooks,git-post-receive
I am working on a post-receive hook on a bare repo. I want to get the file names that are changed and pushed in this bare repo (only the latest one). To get it i am using this command. git diff --name-only HEAD^ This gives me error when I push...

Git Post-receive hook with part of work tree

wordpress,git,deployment,githooks
I would like to use git to deploy to a website to a testing server. My website is a wordpress theme built with gulp and the repository looks like theme.git/ -- gulpfile.js -- src/ -- build/ I've followed the steps explained here and here which are- set up a bare...

Automatically copy pushed files from one GitHub repository to another

git,github,github-api,githooks
I have two GitHub repositories. I'd like to automatically (probably using hooks and/or github API) commit and push files to the second repository when they are pushed to the first one. The second repository is not a clone of the first one, their folder layout is not necessarily the same...

Executing git-hooks on windows errors out

regex,windows,git,githooks,git-bash
So, I have written a simple git-hooks for pre-push which works just fine on Linux or Mac, but doesn't work on Windows. Script: Tries to match the commit message with a regular expression, and should return 0 if matches or else exit. Based on the articles I read, they say...

local atlassian stash server error debugging plugin

githooks,atlassian-stash
Im trying to setup a dev environment to create a git hook plugin for Atlassian stash server. When I run atlas-debug to start the web server then browse to localhost:port The Stash home page doesn't display and I get this error in the console... [INFO] [talledLocalContainer] 2015-03-10 21:09:51,279 WARN [threadpool:thread-15]...

Why are Git post-receive hooks typically in bare repos?

git,githooks,git-post-receive
Most mentions of post-receive hooks that I have seen are set up in bare repos. Why is this? If I only want pushes to the master branch to get deployed to my public_html folder, and all of my pushes are going to a bare repo with a post-receive hook, doesn't...

Git hooks in PHPStorm on Mac

osx,git,bash,phpstorm,githooks
I've got problem with commiting in PHPStorm with pre-commit hook enabled. #!/bin/sh cd "$(git rev-parse --show-toplevel)" # Message message () { if [ $2 -ne 0 ] then echo "${1}: Error" exit 1 else echo "${1}: Success" fi } # JSHint grunt lint:js &> /dev/null message "JSHint" $? # Unit...

Git post-receive hook for push-to-deploy only works with master

git,githooks
I have a remote bare git repository created following: @server:~$ mkdir -p /home/myuser/domain.git && chmod 770 /home/myuser/domain.git && cd /home/myuser/domain.git && git init --bare With a post-receive hook: @server:~$ nano hooks/post-receive The hook script is: #!/bin/sh git --work-tree=/var/www/domain --git-dir=/home/myuser/domain.git checkout -f It has permission to execute: @server:~$ chmod +x hooks/post-receive...

Can a pre-commit Git hook zip a directory and add it to the repository?

wordpress,git,githooks
I'm doing development on a Wordpress plugin. My development directory contains a lot of development-specific stuff (e.g. Grunt files, Sass files, the git repository itself, etc.). Obviously, I don't want to distribute this folder containing all of those development files; people don't want a few MB of Grunt files when...

Integrating multiple git users with Asana

git,githooks,asana,github-for-windows
I've setup a Git server according to this page. I've also incorporated a post-receive hook according to this page. I'm using GitHub for Windows to communicate between my local machine and the git repo. My issue is that the post-receive hook utilizes a variable found in git config user.asana-key. I've...

Redirecting a git push

git,jenkins,githooks,git-push,git-repo
I am currently playing with hooks to get our repositories to tell Jenkins to build, etc. I have been looking for information on how I would be able to redirect a push to another repo, or even if this is possible? So for example developer pushes to Dev repo, pre-push...

Development best practices: automatically grant permission to application's new folders

project-management,githooks
Some functionalities require new folders in my application and sometimes I need to grant write permissions to those folders. At the moment, when I upload the code to production environment, I need to manually grant those permissions in the server. When another person at my development team pulls my code...

Git push error pre-receive hook declined

gitlab,githooks
I have run gitlabhq rails server on virtual machine, following 1-6 steps from this tutorial https://github.com/gitlabhq/gitlab-recipes/blob/master/install/centos/README.md and starts rails server executing command sudo -u git -H bundle exec rails s -e production. After that I created user, using admin tools and created new project under this user. Then I'm trying...

Multiple git hooks for the same trigger

git,githooks
I have a post-checkout hook that I use locally in all of my repos (it renames my tmux session to repo-name/branch-name) For a project I am working on, we just added a post-checkout hook that we're asking the whole team to use. I don't want to add my personal hook's...