githooks

Including submodules in git checkout to GIT_WORK_TREE in hook

纵饮孤独 提交于 2019-12-07 05:09:37
问题 Is it possible to include submodules when using the following code in a post-update hook? GIT_WORK_TREE=/path/to/directory git checkout -f What other options would I have to distribute code, including submodules from a post-update hook? Thanks. 回答1: The question "Using git submodule update --init on a post hook" mentions the error message you could see if using this in your post-update hook: GIT_WORK_TREE=/path/to/directory git submodule update --init That would give a: remote: You need to

Executing a git-hook after pull --rebase

╄→尐↘猪︶ㄣ 提交于 2019-12-07 05:06:37
问题 I'd like to have a hook run after doing git pull --rebase in order to check if a certain file was changed. Something along the lines of this hook. I initially thought of using the post-rewrite hook, however that only works when commits are being rewritten, and won't run when the pull operation simply fast-forwards the branch, which is very often. Any ideas will be appreciated. 回答1: I ran strace git pull --rebase on a local repository, which performed a fast-forward update... First, rewinding

Commit message hook on github

烂漫一生 提交于 2019-12-07 04:37:28
问题 I am trying to setup a pre-receive hook in github that I used to use on STASH. In STASH, I had a pre-receive hook that used to enforce "A custom commit message that should have a JIRA number included in it". Now, I am trying to understand what would be the best way to do something similar on github. If I split it up, it would be: Requiring a custom commit message. Every commit should include an existing JIRA. Enforce this on any pull request as well. Eg: TEST-1 Adding the first commit message

Git global hooks and project hooks

旧时模样 提交于 2019-12-06 23:31:46
问题 Currently I'm using git config --global core.hooksPath ~/.git/hooks to configure global hooks for all my git projects. But if those projects contain hooks, they're not run. I'd like to run the global hook as well as the project hooks. Thank you! 回答1: I think the only way is for your global hooks to check if a corresponding local hook exists and run it. This is not a complete solution because some hooks (pre-push, for example) accepts standard input in addition to command line parameters. If

Git post-receive hook. Move everything except a few folders

不打扰是莪最后的温柔 提交于 2019-12-06 18:16:30
I have implemented a post-receive hook on my server (git was initialized with git init --bare ). Hook was created in the following way: cd repo/hooks/ touch post-receive chmod 777 post-receive Then inside of the file I have: #!/bin/sh GIT_WORK_TREE=/var/www export GIT_WORK_TREE git checkout -f Right now when I push my local changes everything gets moved to /var/www folder. The problem is that I do not want some of the folders to be moved. For example I have folder1 , and folder2 there which I do not want to be moved. Currently I am manually removing these folders after the push, but this is a

How to manually run a git pre-commit hook, without attempting a commit?

ε祈祈猫儿з 提交于 2019-12-06 16:34:51
问题 I just want to be able to run it to see if the code in my working tree passes it, without actually attempting a commit. 回答1: Just run the pre-commit script through shell: bash .git/hooks/pre-commit 回答2: There's a Python package for this available here. Per the usage documentation: If you want to manually run all pre-commit hooks on a repository, run pre-commit run --all-files . To run individual hooks use pre-commit run <hook_id> . So pre-commit run --all-files is what the OP is after. 来源:

Git post-receive hook not working properly

空扰寡人 提交于 2019-12-06 16:29:19
I have a server with a git repository. Each time I make a push to that server I would like to regenerate my gitstats documentation for that repository. In that machine if I execute the following command, the gitstats documentation it's refreshed properly: gitstats /home/<username>/<proyect-name>/htdocs/ /home/<username>/gitstats And here it's my post-receive hook in the repository in that server: #!/bin/sh gitstats /home/<username>/<proyect-name>/htdocs/ /home/<username>/gitstats So when I make a push to that machine, it tries to execute that command, but it doesn't work correctly, the output

git hook to create staging branch

丶灬走出姿态 提交于 2019-12-06 16:09:25
问题 I am hosting my code on Bitbucket. The webhooks are not adequate to solve my issue, so I am hoping git hooks will work. Since I don't imagine they will work server-side, the git hook should be propagated to each checkout on each developers machine. (I know this might be an issue since its normally a local file, but I can hopefully solve it using information from here) I want to create a git hook that will push changes to staging branches. Meaning, if I am a user named bob and I want to push

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

痴心易碎 提交于 2019-12-06 16:09:10
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 However, it only changes the website when I push to the master branch. Why? The remote HEAD is always master , even if I push to another branch. VonC By default, it checkout the

How to know the “remote” in git pre-push hook file

我怕爱的太早我们不能终老 提交于 2019-12-06 15:37:34
In the "pre-push" file, I can get some params using " read local_ref local_sha remote_ref remote_sha ", but I wanna do some restrictions stuff according to the specific remote repo(yes, there's mutiple remote address in my project), so how can I do this? Thanks in advance! remote name and url are supplied as parameters to the pre-push. remote="$1 url="$2" will give the information you needed 来源: https://stackoverflow.com/questions/40837679/how-to-know-the-remote-in-git-pre-push-hook-file