githooks

git pre-push hook, don't run if is --tags

拟墨画扇 提交于 2019-12-10 13:37:01
问题 I have a prepush hook that tests my code, however, it also runs when I do a git push --tags . Is there any way to avoid this? Maybe there's some way to check if its a regular push or if its a --tags push? Update - These are the only arguments I was able to find: $1 is the name of the remote $2 is url to which the push is being done 回答1: I have a solution to this, but it's really kludgey. A while back, I set up a pre-commit hook to stop me from accidentally using -a when I have files staged.

How can I automagically make a checkout upon push?

人走茶凉 提交于 2019-12-10 10:22:29
问题 Consider the following situation: I have a git repository foo.git that contains code of a javascript project. In this repository there is a branch production that contains the state of the code as served by a web-server which fetches the code from /var/www/foo . This repository is the master repository for the project. Everybody pushes and pulls from/to it. Is it possible to have /var/www/foo updated to a checkout of production whenever someobody pushes to that particular branch? You may

from command line ok but the hook (git)

﹥>﹥吖頭↗ 提交于 2019-12-10 10:18:31
问题 I want to automatically update my redmine project repository after anybody pushes into remote repo. Currently gin in redmine is up and works fine. But after automatic update using a hook I get The entry or revision was not found in the repository. in redmine. To set up git in redime I followed redmine wiki so the repo is bare created via git clone --bare To update redmine's git repository I use this cd /srv/www/redmine.domain.com/git_repositories/linode.git && git fetch && git reset --soft

managing website on windows using git

跟風遠走 提交于 2019-12-10 09:42:46
问题 I have a website that is running on a Windows 2008 server. I want to know what is the best way to manage that site using git. Ideally I want an automated deployment, using a post-receive hook or similar. I do have a Linux server that I typically use as my git origin server, so I can utilize that if it makes things easier. Typically my post-receive file there looks like this: #!/bin/sh GIT_WORK_TREE=/var/www/example.com git checkout -f Obviously that won't work as-is on Windows without

git - checkout single file under bare repository

旧城冷巷雨未停 提交于 2019-12-09 15:26:42
问题 On the server I have bare repository which is origin for development process and to simplify deployment to QA environment. So in post-receive it simply does GIT_WORK_TREE=/home/dev git checkout -f But as product gets more complicated there are some other things should be happening. So now it is handled by deploy.sh script which is also tracked by repository. So what I want to do is to be able instead of checking out whole repository is to checkout only deploy.sh and run it. I thought

git pre-commit or update hook for stopping commit with branch names having Case Insensitive match

泄露秘密 提交于 2019-12-09 07:34:27
Is there a way to write a git pre-commit hook to stop commits with identical names with the only difference being upper and lower cases. e.g branch name 1 : firstBranch branch name 2 : FirstBrancH branch name 3 : firsTbranch but branch name: firstbranchname should be allowed. if a commit is done at time T for the branch name firstBranch , then at T+n , Commit with branch name "FirstBrancH" or any combination, git pre-hook would not allow commit. This needs to be a server hook, as client hooks can be pypassed easily. so my thoughts are: so i get the $NAME of the branch being committed to , then

Automatically run Git hook when creating a Git tag

左心房为你撑大大i 提交于 2019-12-08 17:26:38
问题 Is there a Git hook which can be executed when a new Git tag is added? Because I want to automatically write new Git tag names into a textfile. Do you have a clue on how to do this? 回答1: While it's not currently possible using hooks, you can always create a simple script. mytag.sh : #!/bin/sh [ -z "$1" ] || ( git tag $1 && git tag > /path/to/your-tags-file ) then : chmod +x mytag.sh git config alias.mytag !/path/to/mytag.sh 来源: https://stackoverflow.com/questions/4309759/automatically-run-git

Best way to debug git-hooks

孤人 提交于 2019-12-08 14:46:52
问题 What is the best way to debug git-hooks? The way I prefer is adding statements to add output to a log file. For example, the following. echo 'post-receive executed' >> hooks.log Is there a better approach or way to do logging? 回答1: This is an old question, but for future readers, one recommendation would be : Debugging the hook as a shell script I doubt that it is the script itself which needs to be looked at, however if that turns out to be the case, then the next step is to do what you

git pre-commit or update hook for stopping commit with branch names having Case Insensitive match

妖精的绣舞 提交于 2019-12-08 06:03:56
问题 Is there a way to write a git pre-commit hook to stop commits with identical names with the only difference being upper and lower cases. e.g branch name 1 : firstBranch branch name 2 : FirstBrancH branch name 3 : firsTbranch but branch name: firstbranchname should be allowed. if a commit is done at time T for the branch name firstBranch , then at T+n , Commit with branch name "FirstBrancH" or any combination, git pre-hook would not allow commit. This needs to be a server hook, as client hooks

How to call a script from the server, when 'git push' to the git Gogs repository?

你离开我真会死。 提交于 2019-12-08 05:06:05
问题 I need to run the script on my server, when calling git push from the local repository to the git gogs repository #!/bin/sh git pull origin test source env/bin/activate pip install --upgrade pip pip install -r requirements.txt python manage.py migrate python manage.py collectstatic --noinput sudo systemctl restart gunicorn.service sudo systemctl restart celery-worker.service sudo systemctl restart celery-beat.service Subtracted on the Internet - that you need to use git Hooks. Figured out how