[Solved] Git post-commit hook not executing


#1

I’ve recently set up a project with a Git post-commit hook but it appears that the hook is not executed upon commit from within Atom (ie; using the Git Tab in the editor).

The contents of the post-commit file is as follows, where x is a valid remote repository and y a valid branch:

#!/bin/sh
git push x y

Notes:

  • I am running Atom 1.22.0 x64 on Windows 10
  • The hook is executed as expected when the commit is run from the command line (Bash on Win10)
  • The post-commit file is executable

What am I missing?

Any help would be much appreciated!


#2

I just gave this a try on macOS 10.12.6 and it worked ok for me - if you try this simple post-commit hook that creates a file, does it work for you when committing from Atom?

#!/bin/sh

touch test.dat

#3

Thanks Robert - that has shed some light on the issue.

The hook is executed and a touch xxx does create a file.

I’ve since managed to capture the output using git push x y &> output.txt and discovered a Host key verification failed error.

So - it seems my issue is not what I thought it was and more to do with managing SSH keys.

I’m off to do some searching, thanks again!


#4

Issue sorted - it turns out that I wasn’t copying my SSH key files to the right place.

Note for other Windows users, these should be copied to C:/Users/[username]/.ssh/ for Atom to pick up on them.