Deep Dive in Git & GitHub for DevOps Engineers.

Deep Dive in Git & GitHub for DevOps Engineers.

#90 Days of DevOps Challenge - Day 9

  • What is Git and why is it important?

    Git is a version control system that enables collaboration and efficient management of code changes. It tracks modifications to files, allowing users to view the history, revert to previous versions, and merge changes made by multiple contributors. Git's key benefits include facilitating collaboration, enabling branching and merging for parallel development, providing a backup and recovery mechanism, and supporting open-source collaboration. In summary, Git simplifies code management, enhances teamwork, and ensures the integrity of software projects.

  • What is the difference between Main Branch and Master Branch??

    The difference between the "main" branch and the "master" branch is primarily a matter of naming conventions and the desire for inclusive language. Historically, "master" was commonly used as the default branch name in Git, but due to its potentially negative connotations, many communities and organizations have transitioned to using "main" instead. Functionally, both branches serve the same purpose of representing the primary branch where the latest stable code resides. The choice between "main" and "master" is a matter of personal preference and promoting inclusive language practices.

  • Can you explain the difference between Git and GitHub?

    Git is the underlying version control system that allows you to track changes locally, while GitHub is a web-based platform that hosts Git repositories and provides additional collaboration and project management features. GitHub makes it easier to share, collaborate, and contribute to Git repositories, particularly in a team or open-source environment.

  • How do you create a new repository on GitHub?

    Already, I have written a blog in brief about creating the repository please go to this link and check it out.

    Link:- https://devesh121.hashnode.dev/basic-git-github-for-devops-engineers#heading-exercise-1-create-a-new-repository-on-github-and-clone-it-to-your-local-machine

  • What is the difference between local & remote repositories? How to connect local to remote?

    The difference between a local repository and a remote repository lies in their locations and purposes.

    Local Repository :- A local repository is located on your local machine, such as your computer or laptop. It is a copy of a Git repository that resides on your hard drive. The local repository contains all the files, commit history, branches, and other version control information related to your project. You can perform Git operations, such as making commits, creating branches, and merging changes, directly on your local repository without requiring an internet connection.

    Remote Repository :- A remote repository is hosted on a remote server or a cloud-based platform, such as GitHub, GitLab, or Bitbucket. It serves as a centralized location for collaborating with others and sharing your code. Remote repositories allow multiple developers to access and contribute to a project simultaneously. They provide a way to synchronize changes made by different team members and provide a backup and sharing mechanism for your codebase. Remote repositories also offer additional features like issue tracking, pull requests, and project management tools.

    Now for connecting local to remote

    1 . First, create a remote repository on a hosting platform like GitHub.

    2. Navigate to the directory of your local project in the terminal and initialize a Git repository using the command git init.

    3. Add a remote link using the git remote add command to add a remote link between the local repository and the remote repository.

      git remote add origin < paste_remote_repository_url>
    

    4. Now we can push our local repository's commits to the remote repository using the git push command. For example, to push the main branch, we will use :

      git push origin main
    

    This command pushes the commits from our local main branch to the main branch of the remote repository.

    5. After following these steps, our local repository is now connected to the remote repository

  • Tasks

task-1:- Set your user name and email address, which will be associated with your commits.

For setting our user name and email address to the GitHub repo we will use the below commands

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

We can check that associate Usernames and Emails ID using these commands

task-2:-

  • Create a repository named "Devops" on GitHub

  • Connect your local repository to the repository on GitHub.

    1. First, clone the GitHub repository to the local system

2. Now Initialize Git in your local repository and navigate to your local repository's directory using a command-line interface and run the following command to initialize Git:

    git init

3. Add the remote origin URL from your local repository using the below command

    git remote add origin <repository_url>
    git remote -v  # for checking existing remote url or locations
  • Create a new file in Devops/Git/Day-02.txt & add some content to it

  • Push your local commits to the repository on GitHub

we are pushing our changes to our github repository

Those changes are reflecting here on our Github repo

Thank you for taking the time to read this article on DevOps and #90daysofDevOps! I sincerely hope you found it helpful and informative.

If you have any questions or suggestions for improvements, please don't hesitate to reach out. Your feedback is valuable to me.

Wishing you continued success and happy learning on your DevOps journey!

Happy Learning !!!!!!!!!!!!!!!!!!!!!!!!!!!!