Git bare
Create a folder to deploy to¶
ssh into your prodctionserver and create folders:
ssh user@server.com
mkdir ~/repos
mkdir ~/actual-code
Add bare repository¶
cd ~/repos
git init --bare production.git
Add the post-receive hook script¶
sample post-receive under ~/repos/hooks/
folder
#!/bin/sh
FILE_DIR=~/actual-code
BARE_DIR=~/repos/production.git
git --work-tree=$FILE_DIR --git dir=$BARE_DIR checkout -f deploy
chmod +x post-receive
Add remote-repository localy¶
cd ~/path/to/working-copy/
git remote add server ssh://username@yourserver.com:/root/repos/production.git
Push to the production server¶
git push server main:deploy
Link: https://thilinatlm.medium.com/quick-web-deployments-using-git-bare-repositories-2e6e1ceaa06e Link: https://gist.github.com/noelboss/3fe13927025b89757f8fb12e9066f2fa
Git search¶
git log -S "search string" --reverse --patch