AWS Builder Center
From Linux to AWS: Understanding the Journey of Code from Your Laptop to the Cloud

From Linux to AWS: Understanding the Journey of Code from Your Laptop to the Cloud

A practical guide showing how code moves from a Linux-based EC2 instance to GitHub and then to another EC2 instance using Git. Learn the complete workflow of creating, staging, committing, pushing, and cloning a project for cloud collaboration and DevOps.

Series: AWS Mini Projects (1 article)

  1. 1
    From Linux to AWS: Understanding the Journey of Code from Your Laptop to the Cloud This article

From Linux to AWS: Understanding the Journey of Code from Your Laptop to the Cloud

Introduction

In cloud and DevOps, code often needs to move between different environments. Git and GitHub make this process simple by allowing us to create, track, store, and share code across multiple systems.
In this article, we will follow a practical workflow where a project is created on one Amazon EC2 instance, pushed to GitHub, and then cloned onto another EC2 instance.

1. Setting Up Git on EC2

First, we prepare the EC2 instance by updating the system and installing Git.
sudo su
yum update -y
yum install git -y
git -v
which git
These commands install Git and verify that it is available on the system.

2. Creating the Project

Next, we create a project directory and initialize a Git repository.
mkdir git-demo
cd git-demo
git init
touch F1 F2 F3
ls
The  git init  command creates a new Git repository. The files are initially present in the Working Area, where we create and modify them.

3. Stage and Commit the Project

We now move the files to the Staged Area and save them in the Local Repository.
git add .
git status
git commit -m "Initial commit"
git status
Here,  git add  stages the changes, while  git commit  saves them as a version in the local repository.

4. Push the Project to GitHub

After committing the project, we connect the local repository to GitHub and push the changes.
git remote add origin "YOUR_GITHUB_REPO_URL"
git push -u origin main
We can verify the repository status and commit history using:
git status
git log --oneline
GitHub now acts as the central remote repository for our project.

5. Clone the Project on Another EC2 Instance

The same project can now be accessed from another EC2 instance.
mkdir secondDir
cd secondDir
git clone "YOUR_GITHUB_REPO_URL"
ls
The  git clone  command downloads the repository from GitHub and creates a local copy on the second EC2 instance.

6. Complete Workflow

The complete journey of the project is:
Working Area → Staged Area → Local Repository → GitHub → Another EC2 Instance
EC2 Instance #1
↓
Create / Modify Files
↓
Working Area
↓
git add
↓
Staged Area
↓
git commit
↓
Local Repository
↓
git push
↓
GitHub
↓
git clone
↓
EC2 Instance #2
This workflow allows the same project to be shared between different EC2 instances through GitHub.

Conclusion

Linux, Git, GitHub, and Amazon EC2 can work together to create a simple cloud development workflow.
The process can be summarized as:
Create → Stage → Commit → Push → Clone → Collaborate
Understanding this workflow provides a practical foundation for learning cloud computing and DevOps.

Series: AWS Mini Projects (1 article)

  1. 1
    From Linux to AWS: Understanding the Journey of Code from Your Laptop to the Cloud This article
Any opinions in this article are those of the individual author and may not reflect the opinions of AWS.
Enjoyed reading this content? Let the author know!

Your likes, comments, shares, and saves help creators reach more builders.

Loading recommendations

Loading article