• Что бы вступить в ряды "Принятый кодер" Вам нужно:
    Написать 10 полезных сообщений или тем и Получить 10 симпатий.
    Для того кто не хочет терять время,может пожертвовать средства для поддержки сервеса, и вступить в ряды VIP на месяц, дополнительная информация в лс.

  • Пользаватели которые будут спамить, уходят в бан без предупреждения. Спам сообщения определяется администрацией и модератором.

  • Гость, Что бы Вы хотели увидеть на нашем Форуме? Изложить свои идеи и пожелания по улучшению форума Вы можете поделиться с нами здесь. ----> Перейдите сюда
  • Все пользователи не прошедшие проверку электронной почты будут заблокированы. Все вопросы с разблокировкой обращайтесь по адресу электронной почте : info@guardianelinks.com . Не пришло сообщение о проверке или о сбросе также сообщите нам.

From EC2 to GitHub: Connecting Your Cloud Code Like a Pro

Lomanu4 Оффлайн

Lomanu4

Команда форума
Администратор
Регистрация
1 Мар 2015
Сообщения
1,481
Баллы
155
Hey DevOps explorer! ? Today we're diving into Project 2 of my 7-Day DevOps Challenge, where I connect my Java web app hosted on AWS EC2 to GitHub using Git. By the end of this post, you’ll understand how to:

✅ Install Git on your EC2 instance

✅ Set up a GitHub repo

✅ Track and commit code

✅ Push code from EC2 to GitHub using a personal access token

? Why This Matters


Version control is a must-have skill for any developer. Whether you're flying solo or collaborating on a team, Git and GitHub help you keep your code safe, traceable, and easy to manage.

☁ Step 1: Install Git on EC2


sudo dnf update -y
sudo dnf install git -y


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


Git is a version control tool that tracks your code changes. Installing it lets you start managing your code history on the server itself.

? Step 2: Set Up GitHub & Create a Repo


Head to

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

, create a free account (if you haven’t), and start a new repository — this is where your code will live in the cloud.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? A GitHub repository is like a magic folder that tracks every change in your project.
? Step 3: Initialize Local Git Repo


git init


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


This sets up Git inside your project folder on EC2, creating a master branch.

✍ Step 4: Track and Commit Code


git add .
git commit -m "Initial commit"

git add . stages your files, and git commit saves the snapshot. Think of it as telling Git, “Hey, these are the changes I care about.”

? Step 5: Link to GitHub and Push


First, copy the HTTPS URL from your GitHub repo. Then:


git remote add origin

Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.


git branch -M master
git push -u origin master

Oops! Git might ask for your username and password, but GitHub no longer accepts passwords.

? Step 6: Use a GitHub Token Instead


Go to GitHub → Settings → Developer Settings → Personal Access Tokens.

Generate a token with repo access and copy it. Use it when Git asks for a password.


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.



? A GitHub token is a secure key that acts like a password for Git operations.
? Bonus: Editing & Pushing Again


I updated index.jsp, then ran:


git add .
git commit -m "Updated homepage"
git push

And just like that—my changes appeared live in the GitHub repo. Magic!

? What I Learned


Services used: EC2, Git, GitHub, VS Code

Concepts learned: version control, repo setup, staging/commits, GitHub tokens

⏱ Project Reflection


This project took me around 2 hours. The trickiest part? Setting up GitHub authentication.

The best part? Watching my code go live in my repo with one command.

This is just the beginning. Stay tuned for Project 3 tomorrow—CI/CD, here we come! ?


Пожалуйста Авторизируйтесь или Зарегистрируйтесь для просмотра скрытого текста.

 
Вверх Снизу