Mastering Git and GitHub: A Comprehensive Guide for DevOps Mastery 🚀

Mastering Git and GitHub: A Comprehensive Guide for DevOps Mastery 🚀

What is Git and why is it important 🤔

Git is a distributed version control system designed to track changes in source code during software development. It allows multiple developers to collaborate on a project simultaneously without interfering with each other's work. Its importance lies in:

  • Collaboration: Git facilitates seamless collaboration among developers, enabling them to work on the same codebase efficiently.

  • Versioning: Git keeps track of changes, providing a history of modifications, and allowing you to revert to previous states if needed.

  • Branching: Git allows the creation of branches, enabling developers to work on features or bug fixes independently before merging them back into the main codebase.

Difference between Git and GitHub?

Git is a version control system that operates locally on a developer's machine, while GitHub is a web-based platform that uses Git for version control and provides additional collaboration and project management features. Developers often use Git for version control during local development and then push their code to GitHub for collaboration with a larger team.

What is the difference between local & remote repositories?

  1. Local Repository🖥️:

    • A local repository is a copy of a project's version control history that is stored on your local machine.

    • It contains all the files needed to track the changes to your project.

    • You can commit changes to your local repository, view the project history.

  2. Remote Repository🌐:

    • A remote repository is a repository that is hosted on a server.

    • It serves as a central hub where multiple developers can collaborate on a project.

    • Remote repositories are often used to share code with others and to create a centralized point for collaboration.

Configure your identity for version control.

Open your terminal and run the following commands:

git config --global user.name "UserName"
git config --global user.email "emailaddress@example.com"

Replace "UserName" and "emailaddress@gmail.com" with your GitHub username and email

Harmonizing Local and Remote Repositories

Create a repository named "DevOps" on GitHub 🌐

  1. Go to GitHub.

  2. Log in or create a new account.

  3. Click the "+" sign in the top right corner and select "New repository."

  4. Name it "DevOps" and click "Create repository."

Connect your local repository to the repository on GitHub 🔗

  1. Navigate to your local project directory in the terminal.

  2. Run the following commands:

git init
git remote add origin https://github.com/UserName/DevOps.git

Replace "UserName" with your GitHub username.

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

  1. Navigate to the "DevOps/Git" directory in your terminal.

  2. Create a new file named "Day-02.txt" with your preferred text editor.

  3. Add some content to the file.

Push your local commits to the repository on GitHub

Run the following commands:

git add .
git commit -m "Added Day-02.txt"
git push -u origin master

Check your GitHub repository and you will see your newly added file in the repository.