Skip to content

Instantly share code, notes, and snippets.

@devinrhode2
Last active November 18, 2018 23:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save devinrhode2/ce5c043579e0ef9ebb8d7e374f0dcf25 to your computer and use it in GitHub Desktop.
Save devinrhode2/ce5c043579e0ef9ebb8d7e374f0dcf25 to your computer and use it in GitHub Desktop.
git post/pre-push hook to upload changes over ftp

git pre-push/post-push ftp upload code

I'm looking to share what I've done and potentially get improvements on this code snippet from others - my pre-push hook for pushing to ftp:

$ code .git/hooks/pre-push

Works like a charm, but I'd love to not push unless I know there are no unmerged changes I should pull. I'm not sure how to do that. I know, if there are changes, a git hook should do exit 1 to abort the git push.

I searched around for a post-push hook but that proved to be a much more daunting task, because git does not have a post-push hook.

I created this gist for seo reasons, so others can find this - please comment over here though: git-ftp/git-ftp#478

#!/bin/sh
# Using a fixed up fork of felipec/git-remote-hg
# Needed to do this to my $PATH:
# https://stackoverflow.com/questions/27399461/my-custom-git-subcommands-have-stopped-working
echo "issuing *git ftp push* command..."
git ftp push
if [ $? -eq 0 ]; then
echo OK
else
exit 1
fi
echo "*git ftp push* command finished"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment