Created
April 10, 2013 00:44
-
-
Save alanyoshida/5350762 to your computer and use it in GitHub Desktop.
Como fazer deploy para o servidor com o git
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
############################################### | |
# Como fazer deploy para o servidor com o git # | |
############################################### | |
# Na sua Maquina | |
# Crie uma pasta | |
$ mkdir repo && cd repo | |
# Inicie um repositorio vazio | |
$ git init | |
Initialized empty Git repository in /home/thiagobelem/website/.git/ | |
# Crie um arquivo qualquer | |
$ touch index.html | |
# Adicione o arquivo | |
$ git add index.html | |
# De commit no arquivo | |
$ git commit -q -m "Repositorio Local criado e commitado" | |
# No Servidor Remoto | |
mkdir repo.git && cd repo.git | |
# Crie um repositorio vazio | |
$ git init --bare | |
#Initialized empty Git repository in /home/usuario/repo.git/ | |
# Dentro da pasta repo.git/hooks/ crie o arquivo post-receive e coloque o sequinte | |
$ vim hooks/post-receive | |
#!/bin/sh | |
GIT_WORK_TREE=/var/www/local_do_repositorio git checkout -f | |
# Agora de permissao para o arquivo poder executar | |
$ chmod +x hooks/post-receive | |
# Na sua Maquina | |
$ git remote add repositorio ssh://usuario@IP:/home/usuario/repo.git | |
# Faça o push para o branch master do servidor | |
$ git push repositorio +master:refs/heads/master | |
# De agora em diante é só dar push normal | |
$ git push repositorio |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment