Skip to content

Instantly share code, notes, and snippets.

@sople1
Last active December 22, 2019 13:51
Show Gist options
  • Select an option

  • Save sople1/b4b388614f21e1b6193d834b9afd0f9e to your computer and use it in GitHub Desktop.

Select an option

Save sople1/b4b388614f21e1b6193d834b9afd0f9e to your computer and use it in GitHub Desktop.
GIT: post update for remote update (single server, simple ver.) 2019 checked.
#!/bin/bash
#
# .git/post-update
#
# [Simple Update Ver.]
#
git update-server-info
echo "Starting Updating Process..."
# :: Auto-Pulling script >
GIT_DIR=".git"
#SERVICE_WEB_ROOT="/var/www/html/"
SERVICE_WEB_ROOT="/var/www/html/sample/"
ORDER_WEB="cd $SERVICE_WEB_ROOT"
## switch by branch
branch=$(git rev-parse --symbolic --abbrev-ref $1) # $1=refname
if [ "master"=="$branch" ]; then
# -- Push to WEB when Pushed branch was 'master'
echo "Push to WEB>>"
$ORDER_WEB
git pull origin $branch
else
echo "None updated"
fi
# echo $branch
# switch by branch > end
echo "Updating Process Completed."
# :: Auto-Pulling script > end
exec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment