cloudlaunch/guide

Chapter 04 · Git + GitHub

Set up your repository

Create a GitHub repository, push your website from your computer, then connect the repository to Apache on EC2 for a manual deployment.

1

Create the GitHub repository

On GitHub, choose New repository, name it student-portfolio, and keep the repository public for this beginner workflow. Do not commit private keys or passwords.

2

Initialize your local project

From the folder containing your website files, initialize Git and push the first commit.

Local terminal
cd my-portfolio
git init
git add .
git commit -m "Initial portfolio"
git branch -M main
git remote add origin https://github.com/USERNAME/student-portfolio.git
git push -u origin main
3

Install Git on EC2

Connect to Ubuntu over SSH, install Git, and confirm that it is available.

EC2 terminal
sudo apt update
sudo apt install git -y
git --version
4

Manually deploy the repository to Apache

Clone the repository directly into Apache's document root. Clear the default files first, then set ownership so Apache can serve the site.

EC2 terminal
sudo rm -rf /var/www/html/*
sudo git clone https://github.com/USERNAME/student-portfolio.git /var/www/html
sudo chown -R www-data:www-data /var/www/html
sudo chmod -R 755 /var/www/html
sudo systemctl restart apache2
Update manually: after pushing changes to GitHub, connect to EC2 and run cd /var/www/html, sudo git pull origin main, then refresh your public IP.