Skip to main content

Command Palette

Search for a command to run...

Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers.

Published
3 min readView as Markdown

Introduction to Git

Git is a distributed version control system designed to handle everything from small to very large projects with speed and efficiency. It allows multiple developers to collaborate on projects without interfering with each other's work. Git tracks changes in a set of files over time, providing a history of who made what changes and when.

Importance of Git

  1. Version Control: Git allows developers to track changes in their code, making it easy to revert to a previous state if needed.

  2. Collaboration: Multiple developers can work on the same project simultaneously, merging their changes seamlessly.

  3. Branching and Merging: Git's branching system enables the creation of isolated environments for feature development, bug fixes, and experiments, which can later be merged back into the main codebase.

  4. Distributed Development: Each developer has their own copy of the repository, reducing dependencies on a central server and allowing work to continue offline.

Main Branch vs Master Branch

Traditionally, Git repositories had a default branch named "master." However, in recent years, there has been a move towards using more inclusive and neutral terminology. The default branch is now commonly named "main" to avoid any racial or exclusionary connotations. Functionally, they serve the same purpose - to represent the primary line of development.

Git vs GitHub

Git:

  • Git is a version control system that tracks changes in source code during software development.

  • It runs locally on the developer's machine, allowing for version control without the need for a network connection.

  • Git is primarily a command-line tool, although graphical interfaces exist.

GitHub:

  • GitHub is a web-based platform that provides hosting for software development and a centralized location for version control.

  • It utilizes Git for version control but adds a graphical interface, issue tracking, and other collaboration features.

  • GitHub allows multiple developers to work on the same project and provides a platform for open-source collaboration.

Creating a New Repository on GitHub

Task-1: Set User Name and Email Address

Before creating a new repository, it's essential to configure your Git user name and email address. This information is associated with your commits.

bashCopy codegit config --global user.name "Your Name"
git config --global user.email "lokeshtelange12@email.com"

Task-2: Create a Repository named "Devops" on GitHub

  1. Log in to your GitHub account.

  2. Click on the "+" icon in the top right corner and select "New repository."

  3. Name your repository "Devops" and add a description if desired.

  4. Initialize this repository with a README file and create the repository.

Task-3: Connect Local Repository to GitHub

After creating the repository on GitHub, you need to connect it to your local machine.

bashCopy codegit init
git remote add origin https://github.com/your-username/Devops.git

Task-4: Create a New File in Devops/Git/Day-02.txt

Create a new file named "Day-02.txt" inside the "Git" directory of your local repository. Add some content to it using your preferred text editor.

Task-5: Push Local Commits to GitHub

bashCopy codegit add .
git commit -m "Added Day-02.txt"
git push -u origin main

Replace "main" with "master" if your default branch is still named "master."

Now, your local changes are pushed to the GitHub repository.

Conclusion

Understanding Git and GitHub is crucial for DevOps engineers. Git provides efficient version control, while GitHub extends collaboration capabilities with its web-based platform. By following the provided tasks, you've set up your Git environment, created a GitHub repository, connected your local and remote repositories, and made your first commit. These skills form the foundation for effective DevOps practices and collaborative software development.

More from this blog

Introduction Of DevOps

108 posts