Wednesday, December 10, 2014

Put your existing git repo to amazon EC2 instance


Assumptions:

EC2 Specifications: Ubuntu 14.04
GIT installed,
We have Server details as
    IP Address
    UserName

Steps:

  • Connect to EC2 using ssh connection
ssh <username>@<serverIP>

  • Setup git repo on Amazone EC2 Server: here we are creating bare git reppo, which contents only commits and changes (git details) and not the actual content
mkdir -p project_name/my_project.gitcd project_name/my_project.gitgit init --bare

  • Create post-receive hook: this hook will create actual content of the reppo, at the path you specify as GIT_WORK_TREE
vi hooks/post-receive
And write the following content in the file 
#!/bin/sh
GIT_WORK_TREE=/home/ubuntu/www
export GIT_WORK_TREE
git checkout -f

  • Add remote of EC2 to your local git repo (back to your local terminal)
git remote add production ssh://<username>@<serverIP>:/home/ubuntu/project_name/my_project.git

  • Push your existing repo to that remote
git push production <YOUR_BRANCH>


For more referance:

Special Thanks (for helping me to get understand)
    • Rakshit Menpara 


1 comment:

  1. Email shouldn't be ignored as it's the best medium for exchanging paperwork in a timely method, for example, when it comes to of|in relation to} verifying your player account for withdrawals. Players can contact the Videoslots customer care group by e-mail or live chat. While putting this operator via its paces for our Videoslots on line casino evaluate, we have been more than happy to see a responsive Live Chat operate, the place gamers can receive rapid assistance with minimal fuss. In 2011, a group of Swedish on line casino lovers launched Videoslots – a name identified all over the world as a safe 메리트카지노 and scam-free operator.

    ReplyDelete