Skip to content

Instantly share code, notes, and snippets.

@christophemarois
Last active March 1, 2020 09:31
Show Gist options
  • Save christophemarois/6dd19ced9fa18f587c5f7f834117691b to your computer and use it in GitHub Desktop.
Save christophemarois/6dd19ced9fa18f587c5f7f834117691b to your computer and use it in GitHub Desktop.
Push to a remote non-bare git directory
# on the remote
mkdir my-repo
cd my-repo
git init
git config receive.denyCurrentBranch updateInstead
# on the local
git remote add [remote-name] ssh://[ssh profile name]/[path to repo on the remote]
git push [remote-name] master
# Also relevant
# https://superuser.com/questions/232373/how-to-tell-git-which-private-key-to-use
# https://stackoverflow.com/questions/4565700/specify-private-ssh-key-to-use-when-executing-shell-command
@christophemarois
Copy link
Author

2020 yolo update:

deploy.sh

SSH_CONFIG="ssh_config_id"
DIR="/home/web/app"
PM2_ID="app"

ssh $SSH_CONFIG "mkdir -p $DIR && cd $DIR && git init && git config receive.denyCurrentBranch updateInstead"
git remote add $SSH_CONFIG "ssh://$SSH_CONFIG$DIR"
ssh $SSH_CONFIG "cd $DIR && git checkout ."
git push $SSH_CONFIG master
ssh $SSH_CONFIG "cd $DIR && npm install && pm2 restart $PM2_ID"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment