💎Day 9 - Deep Dive in Git & GitHub for DevOps Engineers.

💎Day 9 - Deep Dive in Git & GitHub for DevOps Engineers.
  • ✔️What is Git and why is it important?

    Git is a distributed version control system (VCS) that helps developers track changes in their code and collaborate with others on software projects. It was created by Linus Torvalds in 2005 and has since become one of the most widely used version control systems in the software development industry.

    It provides a robust and flexible version control system, enabling efficient collaboration, easy code management, and the ability to track changes over time.

  • ✔️What is difference Between Main Branch and Master Branch?

    In Git, the main or master branch is like the main timeline of your project. It's the default branch where the latest, most stable version of your code lives.

    1. Master Branch:

      • Older Term: "Master" used to be the common name for this main branch.

      • Still Used: Many projects still use "master" as the default branch name.

      • Recognizable: People understand "master" as the main branch in Git.

    2. Main Branch:

      • Modern Term: "Main" is a newer, more inclusive alternative to "master."

      • Preferred by Some: Some projects use "main" as the default branch name for a more neutral choice.

      • GitHub Default: GitHub now uses "main" as the default branch name for new repositories.

  • ✔️Difference between GitHub and Git?

  • ✔️How do I create a new repository on GitHub?

    Creating a new repository on GitHub involves a few simple steps. Here's a step-by-step guide:

    1. Login to GitHub:

      • Open your web browser and go to GitHub.

      • Log in to your GitHub account. If you don't have an account, you'll need to sign up.

    2. Navigate to Your Profile:

      • After logging in, you'll be on your GitHub dashboard. Click on your profile picture in the top right corner of the screen.
    3. Go to Repositories:

      • In your profile, find and click on the "Repositories" tab. If you don't have any repositories yet, this section will be empty.
    4. Create a New Repository:

      • On the right side of the Repositories page, you'll find a green button labeled "New." Click on it.
    5. Fill in Repository Information:

      • You'll be taken to a page where you can set up your new repository. Fill in the following information:

        • Repository name: Choose a name for your repository. This will also be part of your repository's URL.

        • Description: Add a brief description of your project (optional).

        • Visibility: Choose whether your repository will be public (visible to everyone) or private (accessible only to you and collaborators).

        • Initialize this repository with a README: If you want to add a README file (a document providing information about your project), check this box.

    6. Create Repository:

      • Click the green "Create repository" button at the bottom of the page.

Congratulations! You've successfully created a new repository on GitHub.

  • ✔️What is difference between local & remote repository? How to connect local to remote?

    A remote repository is hosted on a remote (this could be on the internet or an off-site server; it could even be the same machine in a different path) and is shared among multiple team members. A local repository is hosted on a local machine for an individual user.

    Connecting Local to Remote Repository: To connect your local repository to a remote repository, follow these steps:

    1. Create a Remote Repository:

      • On the platform of your choice (e.g., GitHub), create a new repository.

      • Copy the repository URL.

    2. Initialize Local Repository:

      • Navigate to your local project directory using the command line.

      • Run the following commands to initialize a Git repository and make an initial commit:

          git init
          git add .
          git commit -m "Initial commit"
        
    3. Add Remote Repository URL:

      • Run the following command, replacing <remote-url> with the URL you copied earlier:

          git remote add origin <remote-url>
        
    4. Push Local Repository to Remote:

      • Push your local repository to the remote repository:

          git push -u origin master
        

        Now, your local repository is connected to the remote repository. You can push changes from local to remote using git push and pull changes from remote to local using git pull. This setup enables collaboration and version control in a shared environment.

✔️Task-1:

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

✔️Task-2:

◼️Create a repository named "Devops" on GitHub.

◼️Connect your local repository to the repository on GitHub.

    git init  # Initialize a new Git repository locally (if not already initialized)
    git remote add origin https://github.com/your-username/Devops.git

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

    mkdir -p Devops/Git
    echo "Hello, this is Day 02 content!" > Devops/Git/Day-02.txt
    git add .
    git commit -m "Add Day 02 content"

◼️Push your local commits to the repository on GitHub.

    git push -u origin master

◼️Username for 'https://github.com': Give your Github Username.

◼️Password for 'https://mandgepratik@github.com': Add your Personal Access Token ( PAT ).

◼️Now, if you visit your GitHub repository (https://github.com/your-username/Devops), you should see the "Day-02.txt" file with the content you added. Your local and remote repositories are now connected, and the changes have been synchronized.🎉

✔️Conclusion:

Diving into Git and GitHub provides DevOps Engineers with crucial version control and collaboration skills. This journey ensures proficiency in streamlined development workflows, enabling agile coding practices. The exploration promises valuable insights, empowering engineers for efficient project management in the dynamic realm of software development.

I'm glad to hear that you're confident about the value of your blog! If you have any questions or need assistance with anything related to the content, blogging, or any other topic, feel free to ask.🌟

🎀Happy Learning:) 😊

Did you find this article valuable?

Support PratikM's Blog by becoming a sponsor. Any amount is appreciated!