Deep Dive in Git & GitHub for DevOps Engineers

Deep Dive in Git & GitHub for DevOps Engineers

  1. What is Git and why is it important?

    Git functions as an intelligent time-travel tool for your files, meticulously recording changes, facilitating collaboration, and safeguarding your work. Its significance extends beyond coding, proving invaluable for a wide array of projects.

    why?

    - Version Control: Git empowers you to monitor code modifications, guaranteeing a safety net for easy restoration.

    - Collaboration: Multiple developers can collaboratively work on the same project without conflicts.

    - Error Recovery: In the event of a mistake, Git enables you to revert to a prior code version swiftly.

  2. What is the difference Between Main Branch and Master Branch?

    In Git, the terms "main branch" and "master branch" are frequently used interchangeably. Nevertheless, there has been a trend towards adopting "main" to sidestep potentially offensive language. Both terms denote the default branch of your Git repository, housing the latest stable version of your project.

  3. Can you explain the difference between Git and GitHub?

    Git: The fundamental technology that oversees version control for your code on your local machine.

    GitHub: A web-based platform that amplifies Git's capabilities by offering cloud-based repository storage, fostering collaboration with others, and facilitating project management.

  4. How do you create a new repository on GitHub?

    Step 1: Log in to your GitHub account:

    Open your web browser, go to the GitHub website (https://github.com), and sign in to your GitHub account if you're not already signed in.

    Step 2: Click the "+" icon in the top right:

    In the top right corner of the GitHub homepage, you will find a "+" icon. Click on it to access a dropdown menu.

    Step 3: Select "New repository":

    From the dropdown menu, click on "New repository." This will take you to the "Create a new repository" page.

    Step 4: Enter a name, description, and other settings:

    On the "Create a new repository" page, you'll be prompted to fill in the following information:

    Repository Name: Provide a unique and descriptive name for your repository.

    Description: Optionally, you can add a short description to explain the purpose of your repository.

    Visibility: Choose whether you want the repository to be public (visible to anyone) or private (visible only to you and invited collaborators).

    Initialize this repository with:

    If you want to start your repository with a README file, check the "Add a README file" option. This helps provide information about your project.

    If you want to include a .gitignore file, select a programming language or framework from the dropdown list. GitHub will suggest a .gitignore file for that specific language or framework.

    Click "Create repository":

    Once you've filled in the required information and made your selections, click the "Create repository" button at the bottom of the page.

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

    The local repository resides on your computer, while the remote repository is hosted on a server, such as GitHub.

    To establish a connection between the two, you'll need to initiate the process by creating a remote repository, establishing the link between it and your local repository using "git remote add," and then transmitting your code to the remote repository with "git push."

  6. Task

    \=======

    task-1:

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

      - Once we log in first time to the new repository Git will ask to set username and email before committing and we can set it with the below command

        git config --global user.name "Your Name"
        git config --global user.email "your.email@example.com"
      

Task-2:

  • Create a repository named "Devops" on GitHub

    with a click on the create repository button, we create a repository.

  • As the repository is blank we could see as below.

  • Connect your local repository to the repository on GitHub.

    - with git clone command will clone a repository in the local machine.

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

    -will init the repository and make a new folder and file into it.

  • - Now we add files and commit the changes.

  • -We have successfully committed the changes in a local repository.

  • Push your local commits to the repository on GitHub

    -We can push the changes in the GitHub repository using the below command

    git branch -M

    main git remote add origin https://github.com/kishorchavan87/Devops.git git push -u origin main

  • -We can verify the changes in the GitHub repository.

Thanks,

Kishor Chavan