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

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

ยท

3 min read

In today's fast-paced digital world, collaboration and version control are paramount for successful software development projects. Git emerges as a game-changer, revolutionizing the way teams manage their codebase.

What is Git and Why is it Important?

  • Git, developed by Linus Torvalds, is a distributed version control system designed to track changes in source code during software development.

  • It allows multiple developers to collaborate seamlessly, manage changes efficiently, and maintain a comprehensive history of revisions.

  • Key benefits include:

    • Version Control: Track changes and revert to previous versions easily.

    • Collaboration: Facilitate teamwork by enabling concurrent work on the same project.

    • Branching: Experiment with new features without disrupting the main codebase.

    • Community Support: Leverage a vast community and resources for problem-solving.

Main Branch vs. Master Branch:

FeatureMain BranchMaster Branch
NamingAlso known as "default" or "trunk."Historically used as the primary branch in Git repositories.
TransitionSome organizations have transitioned from "master" to "main."Traditionally the default branch name in Git repositories.
TrendsIncreasingly adopted due to inclusivity and neutrality.Previously used, but now considered outdated by some.

Creating a New Repository on GitHub: Step-by-Step

  1. Log in to GitHub: Navigate to github.com and log in to your account.

  2. Create a New Repository: Click on the "+" icon in the top-right corner and select "New repository."

  3. Name Your Repository: Give your repository a descriptive name.

  4. Add Description: Optionally, provide a brief description of your project.

  5. Choose Visibility: Decide whether your repository will be public or private.

  6. Initialize with a README: If desired, select this option to create an initial README file.

  7. Create Repository: Click the "Create repository" button to finalize.

Local vs Remote Repositories

  • Local Repository:

    • Located on your local machine.

    • Stores your project's files and commit history.

    • Enables offline work and experimentation.

  • Remote Repository:

    • Hosted on a remote server, often platforms like GitHub, GitLab, or Bitbucket.

    • Facilitates collaboration among team members.

    • Serves as a central hub for sharing changes and collaborating.

Connecting Local to Remote Repository:

  1. Initialize Git: Navigate to your project directory in the terminal and initialize Git using git init.

  2. Link Remote Repository: Use git remote add origin <remote_repository_URL> to link your local repository to the remote one.

  3. Push Changes: After making changes locally, commit them using git commit and push them to the remote repository using git push.

๐Ÿ‹๏ธโ€โ™€๏ธ Exercises

Task-1

Set your user name and email address, which will be associated with your commits.

  • Configure User Name: Start by setting your user name associated with your commits using the command git config --global user.name "your name"
  • Set Email Address: Next, set your email address to be linked with your commits:

    git config --global user.email "your email"

Task-2

Create a repository named "Devops" on GitHub

Connect your local repository to the repository on GitHub.

Create a new file in Devops/Git/Day-02.txt & add some content to it

Push your local commits to the repository on GitHub

By mastering Git and understanding its nuances, you empower yourself and your team to streamline development processes, enhance productivity, and build exceptional software products. Embrace the power of Git today!

So, what are you waiting for? Dive into the world of Git and unleash your coding potential!

ย