Deep Dive in Git & GitHub

Deep Dive in Git & GitHub
  1. What is Git and why is it important?

    Git is a Distributed version control system(DVCS). It is founded by Linus Torvalds in 2005. A DVCS is a type of version control system that allows multiple developers to work on same codebase and track changes to the code over time, even if they are located on different machines.

    In DVCS like GIT, each developer has a complete copy of code repo on their local machine, which means they can owner on code even when they are not connected to the internet.

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

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

In the context of version control systems like Git, "Master Branch" and "Main Branch" are two commonly used names for the default branch of a repository.

Traditionally, the default name for this branch in Git was "master," but due to concerns about the potential racist connotations of the word "master," some organizations have started using "main" as an alternative.

In terms of functionality, both the "master" and "main" branches serve the same purpose: they are the default branch that is checked out and used when a new clone or checkout is performed on the repository. Changes made to this branch are typically considered to be the latest stable version of the codebase.

Overall, the difference between "Master Branch" and "Main Branch" is primarily one of naming convention, and the choice of which term to use is up to the individual or organization managing the repository.

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

    Git is a version control system that allows developers to track changes in their codebase over time. It provides a set of commands that enable developers to create, review, and merge code changes to their projects.

    On the other hand, GitHub is a web-based platform that provides hosting services for Git repositories. It allows developers to store and manage their Git repositories in the cloud, collaborate with other developers, and contribute to open-source projects.

    In simple terms, Git is the tool that developers use to manage and track changes in their code, while GitHub is a platform that allows developers to store and share their Git repositories with others. Think of Git as a hammer and GitHub as a tool belt that holds the hammer and other tools.

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

  3. To create a new repository on GitHub, follow these steps:

    1. Log in to your GitHub account.

    2. Click on the "+" sign in the top right corner of the screen.

    3. Select "New repository" from the dropdown menu.

    4. On the "Create a new repository" page, enter a name for your repository.

    5. Optionally, enter a description for your repository.

    6. Choose whether you want your repository to be public or private.

    7. Select the "Initialize this repository with a README" option if you want to add a README file to your repository.

    8. Optionally, choose a .gitignore file and a license for your repository.

    9. Click the "Create repository" button.

Your new repository will now be created on GitHub, and you'll be taken to the repository page where you can start adding files, making changes, and collaborating with others.

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

  2. A local repository is a Git repository that is stored on your local machine, while a remote repository is a Git repository that is stored on a remote server, such as GitHub, GitLab, or Bitbucket.

    The main difference between local and remote repositories is that local repositories are used for making changes to the code and tracking changes, while remote repositories are used for sharing and collaborating on code with others.

    To connect your local repository to a remote repository, you need to follow these steps:

    1. Create a new repository on your remote server (e.g., GitHub).

    2. Copy the URL of the remote repository.

    3. Open your local Git repository using the command line or a Git GUI tool.

    4. Type the following command in the terminal or console to connect your local repository to the remote repository:

    5.  git remote add origin <remote_repository_URL>
      

      Here, "origin" is the name of the remote repository and "<remote_repository_URL>" is the URL of the remote repository that you copied earlier.

    6. Tasks

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

    1. Create a repository named "Devops" on GitHub

  • Connect your local repository to the repository on GitHub.

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

    1. Push your local commits to the repository on GitHub

Here you can see the file Day-02.txt in the central repository.

THAT'S ALL FOR TODAY'S LEARNING I HOPE YOU LEARN SOMETHING FROM THIS BLOG.