githooks

How to properly use post-receive hook?

允我心安 提交于 2019-12-11 07:12:47
问题 My directory structure is: ~/parent.git/.git/hooks/post-receive The post-receive hook looks like: #!/bin/sh git checkout -f When I push into parent.git, the script does not run. I can't figure out the problem, as every bit of the internet says this should work. I chmod'd post-receive, so I know that is not the problem. Any help is much appreciated. 回答1: As Chris mentioned you seem to have the same problem as reset hard on git push Specifically hooks run with CWD and GIT_DIR set to the .git

git - remote: fatal: you are on a branch yet to be born, using post-receive hook

会有一股神秘感。 提交于 2019-12-11 04:10:41
问题 So I am trying to sync to github branches to two parts of my website, theoretically the master branch in my github should be synced with my website tinyweatherstation.com and the beta branch should sync with beta.tinyweatherstation.com, and I have successfully gotten the post-receive hook working with the master branch, but when this for the beta branch: git remote add live_beta ssh://wesley@tinyweatherstation.com/var/www/tinyweatherstation.com.git git push live_beta +beta:refs/heads/beta I

Git hook to detect push --mirror

走远了吗. 提交于 2019-12-11 02:47:21
问题 beside a main Git repository on a server (with Gitolite) I would like to have a possibility for each developer to set up a mirror it's own local repository. That's not difficult. However, I want to disable git push --mirror on the main Git server repository, to prevent mistakes if a developer screw the mirroring. I think the best place is a hook, maybe the update hook. But I cannot find how to detect in a server hook, that push --mirror command has been executed on the client machine. Client

Can one re-stage files in a pre-commit git hook?

这一生的挚爱 提交于 2019-12-11 02:08:41
问题 I've made a powershell script that adds a header to certain files within my project. I want to run it whenever code is in the process of being pushed to GitHub so that all such files in the GitHub repository have the header attached, removing the need to run the script manually. The issue is that when I modify the files in my pre-commit git hook, those changes aren't restaged, so I essentially have to stage, commit and then stage again for the headers to be committed. Is there a good way to

How to copy a pushed branch to another directory?

核能气质少年 提交于 2019-12-10 21:33:29
问题 I have a branch called master (Production) and another called development . When I push a commit from master, the post-receive hook executes: git --work-tree=/var/www/mywebsite.com --git-dir=/var/repo/mywebsite.com.git checkout -f And the website is live. But I want my development branch copied to /var/www/mywebsite.com.dev . 回答1: What you're trying to do by hand is what tools like Capistrano are meant for, and they will do it better (for example, your version is not atomic so your website

Git modify contents of index directly for pre-commit formatting hook

偶尔善良 提交于 2019-12-10 20:48:27
问题 I would like to automatically format my files before they are added to Git's index. Right now, I have a pre-commit hook that looks like this: #!/bin/bash set -e exec 1>&2 workingext="working.$$" ext="bak.$$" git diff -z --cached --name-only | egrep -z '\.(pl|pm|t)$' | \ while read -d'' -r f; do # First modify the file in the index mv "$f" "$f.$workingext" git show :"$f" > "$f" perl -c "$f" perltidy -pbp -nst -b -bext="$ext" "$f"; rm -f "$f.$ext" git add "$f" mv "$f.$workingext" "$f" # Then

Retrieving branch names from within a post-checkout hook

↘锁芯ラ 提交于 2019-12-10 20:41:19
问题 When switching from one branch to another in Git, is there any way to retrieve the names of both branches from within the post-checkout hook? So assuming I were to run the following two commands: $ git branch * branch_a branch_b master $ git checkout branch_b Switched to branch 'branch_b' I'd be looking for the following two strings (in the post-checkout hook): "branch_a" "branch_b" 回答1: You can use git reflog inside your hook to get the previous and next branch. Here a simple working example

How to do a pre-checkout with Git

岁酱吖の 提交于 2019-12-10 18:44:24
问题 I would like to move some files before doing a git checkout on a specific branch, and to execute some scripts. There is no way to do an alias to checkout with my scripts, I really need a hook. I saw many links and it seems the the pre-checkout hook is not yet implemented. Is there a way to do so? 回答1: you can use git stash that grab your local changes. Usually i do next: git stash -u; git checkout <branch>; git stash pop Execute them in one line with && and you will get way to move your

How can I get push user information in server side git hook?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-10 17:02:42
问题 I would like to stop users to delete remote git branch by using server side hooks( update hook ). I have written shell script in update hook to achieve that. Now I am able to stop all users to delete remote git branch, but I want to give delete permission to specific user , to do this we need to get user information(username, useremail) of who is trying the delete operation in server side hook? we have $USER, $GIT_AUTHOR_NAME, $GIT_AUTHOR_EMAIL etc variables to get user information in client

git pre-receive hook - getting the newest code

落花浮王杯 提交于 2019-12-10 15:15:26
问题 I am trying to write a pre-receive hook for git that will pull the latest version of the code being pushed and run unit tests against it. My code is below, but when it gets to "git checkout $newrev", I get: remote: fatal: reference is not a tree: 188de39ca68e238bcd7ee9842a79397f39a5849e What do I need to do to get a checkout of the code being pushed before the receive has happened? #!/bin/bash while read oldrev newrev refname do echo "Preparing to run unit tests for $newrev" TEST_DIR=/opt/git