DevOps  

๐Ÿš€ Add Code to Your GitHub Repository

This guide explains how to add code to your GitHub repository using Git Bash for local Git commands and the GitHub web interface for collaboration.

1. Clone the Repository Using Git Bash ๐Ÿ–ฅ๏ธ

Open your repository page on GitHub.

Click the green "Code" button and copy the HTTPS URL.

git 22

Open Git Bash on your computer and run:

git clone <repository-url>
cd <repository-folder>
Git 2

This downloads the full project to your local machine. ๐Ÿ’ป

2. Create a New Branch in Git Bash ๐Ÿ“Ÿ

Protect the main branch by creating a feature branch:

git checkout -b <branch-name>
Example: git checkout -b version1
Git 3

Work on this new branch to keep changes isolated. ๐Ÿ”’

3. Add or Modify Your Code Files โœ๏ธ

Create new files or modify existing ones locally:

touch index.html script.js
Git 4

Use your code editor to write or edit code in these files. ๐Ÿ“

Git  123

4. Stage and Commit Your Changes with Git Bash ๐Ÿ“ฆ

Stage all changed files:

git add .

Commit the changes with a descriptive message:

git commit -m "Initial Changes"
Git 5

This records your changes locally. ๐Ÿ’พ

5. Push the Branch to GitHub

Push your branch and changes to the remote repository:

git push origin <branch-name>
Example: git push origin version1
gut 6

This uploads your code safely to GitHub's servers. ๐ŸŒ

6. Open a Pull Request Using GitHub Web

Go to the GitHub repository page in your browser.

You will see a suggestion to open a pull request for the new branch.

Git 7

Click "Compare & pull request."

Add a meaningful title and description of your changes.

Git 8

Click "Create pull request." โœจ

Git 9

7. Collaborate, Review, and Merge   ๐Ÿค

Collaborate with your team via the pull request.

Once approved, merge the pull request into the main branch.

Git 10

Optionally, delete the feature branch in the GitHub web interface to keep the repository clean. ๐Ÿงน

Git 11

StepActionTool
Clone repogit clone <url>Git Bash ๐Ÿ–ฅ๏ธ
Create branchgit checkout -b <branch>Git Bash ๐Ÿ“Ÿ
Add/Edit codeWrite code files locallyCode editor โœ๏ธ
Stage & commitgit add .+git commit -mGit Bash ๐Ÿ“ฆ
Push branchgit push origin <branch>Git Bash โ˜๏ธ
Open PRUse GitHub web to create PRGitHub Web ๐Ÿ”—
Review & mergeCollaborate and merge PRGitHub Web ๐Ÿค

Git 12

This workflow combines the power of Git Bash's command-line interface and GitHub's web platform for seamless code addition and collaborative development. ๐ŸŽ‰

Git Related Articles