Git & GitHub: A Beginning for DevOps Engineers Day-9

ยท

3 min read

Overview of Git Git

a potent distributed version control system, is now a vital resource for both DevOps engineers and software developers. Its importance stems from its capacity to effectively track and manage source code changes, facilitating versioning, cooperation, and code integrity.

Master Branch versus Main Branch

The distinction between Git's Main and Master branches is one frequent misunderstanding. Git used to use "Master" as the default branch name, but more inclusive and neutral language is the goal of more recent terminology changes. As a preferred option, the "Main" branch now promotes a polite, diverse environment in the tech community.

Git vs. GitHub: Unraveling the Differences

While Git is the version control system, GitHub is a web-based platform that leverages Git for collaborative software development. Git manages the versioning locally on a developer's machine, while GitHub provides a centralized platform for hosting repositories, collaboration, and additional features like issue tracking and pull requests.

Creating a New Repository on GitHub

Setting up a new repository on GitHub is a straightforward process:

Task 1: Set User Information Before diving into GitHub, ensure your local Git configuration is set up. Use the following commands in your terminal to set your username and email address:

git config --global user.name "Your Name"
git config --global user.email "your@email.com"

Task 2: Create a Repository on GitHub

  1. Log in to your GitHub account.

  2. Click on the "+" sign in the upper right corner and select "New repository."

  3. Name your repository "Devops" and follow the prompts to create it.

Task 3: Connect Local and Remote Repositories

  1. In your local terminal, navigate to the project folder.

  2. Initialize a Git repository if not already done:

git init
  1. Connect your local repository to the GitHub repository:
git remote add origin <repository_url>

Replace <repository_url> with the URL of your GitHub repository.

Task 4: Add a New File and Push to GitHub

  1. Create a new file in the "Devops/Git" directory:
mkdir -p Devops/Git
touch Devops/Git/Day-02.txt
  1. Open "Day-02.txt" and add some content.

  2. Stage and commit changes:

codegit add .
git commit -m "Add Day-02.txt"
  1. Push changes to GitHub:
git push -u origin main

Replace "main" with "master" if your GitHub repository still uses the master branch.

By following these steps, you've successfully created a new repository on GitHub, connected your local and remote repositories, added a new file, and pushed your changes to GitHub.

Mastering Git and GitHub is essential for DevOps engineers, enabling streamlined collaboration and version control. Whether you're working on a solo project or contributing to a team, these skills are fundamental for success in today's software development landscape. Happy coding!

ย