Skip to content

Instantly share code, notes, and snippets.

@devinrhode2 devinrhode2/README.md
Last active Nov 18, 2018

Embed
What would you like to do?
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: https://github.com/git-ftp/git-ftp/issues/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
You can’t perform that action at this time.