git hooks and how they work

So I’m trying to get hudson to build with a post-receive hook. In my local git repo I set post-receive.sample to just post-receive, chmod 755 and added in the line:

/usr/bin/curl -u user:secret http://localhost:8080/hudson/job/MyJob/build?token=secondsecret

If I force a build, hudson updates the code, but here’s what I don’t understand, the hooks in that repo DON’t have the .sample after them like they do locally, and the post-receive in the hudson repo doesn’t have that line of code above. What’s going on here and how are hooks integrated into the whole git process? Do I need to be changing this hook on the remote repo? I would have thought it was enough to do it locally and push so anyone fetching from that repo get the new hooks. I can’t understand how another user’s repo would have different hooks.

  • How is ignore-paths evaluated in git svn?
  • can git be used for version control on non text documents such as word doc or xls etc
  • Is it possible to do a Git Pull --rebase with Visual Studio git tools (and can it be set by default)
  • local git hook for “git remote update”?
  • Git push --force from IntelliJ IDEA
  • Git - How to fix “corrupted” interactive rebase?
  • Is it possible in Git to only stage files that are staged and modified?
  • How do you avoid that people forget to run 'git push'?
  • Update git-svn list of remote branches
  • Managing aesthetic code changes in git
  • git cherry-pick a diff between commits without common history?
  • Using GIT, how can I selectively pull / merge changes from another's 'fork'?
  • 2 Solutions collect form web for “git hooks and how they work”

    You basically have two options:

    1. Place the post-receive hook on the server and let the server run curl.
    2. Place a post-commit hook on your local repo and let your local box run curl.

    As your build job will probably fetch the code to build from the repo on the server, only option 1. makes sense. In case 2., the build job would probably have to fetch the code from your local box, and that is probably not what you want.

    You cannot place hooks onto the server using git push. You (or someone with the appropriate permissions) needs to do that by manually logging into server and modifying the hook script files locally.

    Hooks are not shared through the repository. You need to install the hook at the remote side.

    Git Baby is a git and github fan, let's start git clone.