githooks

Difference between pre-push and pre-receive hook in git?

牧云@^-^@ 提交于 2019-12-03 09:07:26
Is there a difference between pre-push and pre-receive hook in git, in terms of use case or working logic? The only difference I could understand from their documentation was in terms of the input they receive - 1. Pre-Push : Information about what is to be pushed is provided on the hook's standard input with lines of the form - local ref SP local sha1 SP remote ref SP remote sha1 LF 2. Pre-receive : For each ref to be updated it receives on standard input a line of the format - old-value SP new-value SP ref-name LF However, I would like to know if there are particular use cases for each hook

Compress JS/CSS files on deploy using Git

我的梦境 提交于 2019-12-03 08:01:06
I'm kinda new to git. Also, this is my first project where I'm automating the deployment process. So far it's been bliss to being able to do git push dev and have files uploaded, config files copied, etc. Now I want to minify JS/CSS files when I push to my dev server. I was thinking of installing some command-line tool on the server for minifying and for-each js/css file on certain folder, compress and save, on a post-receive git hook. Is this a good approach? (cause I've read about adding compressed files to the repo and other ideas I don't feel quite convinced) If so, which tools are best

Prevent pushes to git containing tabs in certain files (e.g. *.cpp, *.h, CMakeLists.txt)

情到浓时终转凉″ 提交于 2019-12-03 07:01:31
问题 I'd like my remote repository to refuse any pushes that contains a file that contains a tab, but only if the file belongs in a certain class (based on the filename). Is that possible? I have looked a bit at the update hook in githooks, and I think that is the correct one. So in short, a push should be rejected if: there is a file of the listed types ( *.cpp , *.h , CMakeLists.txt ) that contains one or more tab characters. 回答1: Uh oh, this question seems to have slipped through the cracks.

Dissallow deletion of Master branch in git

£可爱£侵袭症+ 提交于 2019-12-03 07:01:22
I'm trying to setup a git hook that will disallow anyone to delete the master, alpha, and beta branches of our repository. Can anyone help with this? I have never done a git hook so i don't want to try my luck in developing my own without a little help. Thanks in advance. Straightforward with a pre-receive hook. Assuming you're using a bare central repository, place the following code in your-repo.git/hooks/pre-receive , and don't forget to chmod +x your-repo.git/hooks/pre-receive . #! /usr/bin/perl # create: 00000... 51b8d... refs/heads/topic/gbacon # delete: 51b8d... 00000... refs/heads

How can I automate Pivotal Tracker & Github Integration?

浪子不回头ぞ 提交于 2019-12-03 06:38:55
问题 Pivotal Tracker and Github have great integration: Once it's set up, each commit which is prefixed by the Pivotal Tracker ID will appear under the corresponding Pivotal Ticket automatically, for an example: git commit -am '[#1234567] my new changes' git push origin will add the comment 'my new changes' automatically to the 1234567 Pivotal Ticket among with the github commit link. However, it's easy to forget to add the ticket ID each time. How could it be simplified / automated? 回答1: The

Writing Git hooks in python/bash scripts [closed]

耗尽温柔 提交于 2019-12-03 05:40:32
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 4 years ago . I have recently needed to write git hooks, for all commits to reference a particular ticket. I was hoping for a place to start learning. All the stuff in the pro git book is written in Ruby. Since Ruby is not my strong suit, can anybody share tutorials about git hooks written in other languages? (I'd

How can I allow git merge commits to master but prevent non-merge commits?

寵の児 提交于 2019-12-03 05:35:11
I have a Git pre-commit hook that prevents me from committing to master unless overridden, in order to encourage developing on branch. However I would like to automatically allow merge commits to master. Is there a way to identify a merge commit from my pre-commit hook script? The script looks like this: #!/bin/bash BRANCH=`git branch --color=never| grep '^*'|cut -c3-` if [ "${BRANCH}D" == "masterD" -a "${GIT_COMMIT_TO_MASTER}D" != "trueD" ] then echo "Commit directly to master is discouraged." echo "If you want to do this, please set GIT_COMMIT_TO_MASTER=true and then commit." exit 1 fi

Automatically synchronizing a Subversion repository and a Git repository

孤者浪人 提交于 2019-12-03 05:19:58
问题 My project has a Subversion repository on a network file system, and a new team would like to access it using Git, and be able to commit to it and get updates from it. What I have in mind is to create a new bare git-svn clone of the Subversion repository on the same network file system, and make sure the two repositories are always up to date with respect to each other. The way to do this is probably to add a post-commit hook for both Subversion and the new Git repository, that will each

How do I hook a git pull on the remote?

那年仲夏 提交于 2019-12-03 02:46:59
Is there a way to hook when a git pull happens on the remote (similar to a pre-receive or post-receive). Basically I'd like to be able to cause the remote to commit whatever it has when there is a pull. In my situation, whatever is live on the remote is an authoritative source which may get modified without a git commit. I want to make sure when I pull I'm always able to get the latest of whatever is live. First, to answer your actual question: there are no hooks invoked on the remote side when someone fetches. (When someone pulls, all the remote knows is that they fetched from it - it doesn't

Using github to write a book [closed]

梦想与她 提交于 2019-12-03 00:02:27
With Github one can write a well-formatted README.md file and document to present the project. Also, there are wiki pages for user to collaborate. I'm wandering what would be an optimal workflow, even for non tech users, to make use of the GitHub platform to write a collaborative book. How to use markdown but then enhance it by applying a stylesheet, make PDF out of it, organise chapters, have a public site (gh-pages) out of it and so on? Is there such a project or tool chain for GitHub? In other word, how to easily write a collaborative book with a nice html and PDF output in GitHub? Thanks.