Git Hooks and Merging Changes

Date: 03.May 2017 | Reading Time: 0 minute, 43 seconds

Any Git experts around? I am trying to modify the way my site gets updated. Right now I am using a post-receive hook to checkout the most recent commit. And that works great, but with the micro.blog iOS app I was thinking about using that for posting. Only problem is that this is not going to end up in my repo and is being overwritten with the post-receive hook every time I push something to the repo.

Right now I am using this hook:

#!/bin/sh
WEB_DIR=/home/user/public_html/pathtoblog

# remove any untracked files and directories
git --work-tree=${WEB_DIR} clean -fd

# force checkout of the latest deploy
git --work-tree=${WEB_DIR} checkout master --force

Is there a way to modify this so it does not clean WEB_DIR but instead commit/merge any changes from WEB_DIR before checkout?