Skip to content

Instantly share code, notes, and snippets.

@renanlara
Forked from alanyoshida/Deploy com Git
Created October 30, 2015 19:00
Show Gist options
  • Save renanlara/54e57e5b360194f5ea10 to your computer and use it in GitHub Desktop.
Save renanlara/54e57e5b360194f5ea10 to your computer and use it in GitHub Desktop.
Fazendo Deploy de um projeto direto para o servidor via ssh usando o git.
# Primeiro crie um repositorio Local.
$ git init
Initialized empty Git repository in C:\Projetos\site\.git
$ cat ' ' > index.html
$ git add index.html
$ git commit -q -m "Iniciando o repositório"
# No Servidor
# Crie Repositorio Vazio
$ mkdir site.git && cd site.git
$ git init --bare
Initialized empty Git repository in /home/git/projetos/site.git/
# Criar arquivo post-receive dentro de site.git/hooks
# GIT_WORK_TREE é o local onde vai ficar os arquivos do projeto
$ vim hooks/post-receive
#!/bin/sh
GIT_WORK_TREE=/var/www/site.com.br git checkout -f
# Permissao de execução no arquivo
$ chmod +x hooks/post-receive
# Maquina Local
# Adicionando o repositorio na maquina local
$ git remote add repositorio ssh://git@IPSERVIDOR:/home/git/projetos/site.git
# Fazendo Push do seu master local para o master do servidor
$ git push repositorio +master:refs/heads/master
# de agora em diante é só commitar e dar push normal
$ git push repositorio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment