90daysofdevops Day 9: Deep Dive in Git & GitHub for DevOps Engineers.
Git + GitHub

90daysofdevops Day 9: Deep Dive in Git & GitHub for DevOps Engineers.

1.What is Git and why is it important?

==> Git is a free and open-source distributed version control system designed to handle everything from small to very large projects with speed and efficiency.

Git is important because it provides a number of advantages over other version control systems, including:

  • Speed: Git is very fast, even for large projects. This is because Git stores changes to files as snapshots, which can be efficiently compared and merged.
  • Efficiency: Git is very efficient with disk space. This is because Git only stores changes to files, rather than entire copies of the files.
  • Scalability: Git can handle very large projects with millions of files. This is because Git stores each file as a separate object, which can be efficiently referenced and shared.
  • Distributed Ness: Git is a distributed version control system, which means that each developer has a complete copy of the repository on their local machine.
  • This makes it easy for developers to work on the same project from different locations, and it also makes Git very resilient to failures.
  • Collaboration: Git makes it easy for developers to collaborate on projects. Git provides a number of features that make it easy to share changes, merge changes from other developers, and resolve conflicts.

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

==>Main branch and master branch are two different names for the primary branch of a Git repository. They are conceptually the same, but there are some subtle differences in how they are used and perceived.

Historically, the master branch was the default name for the primary branch in Git. However, in recent years, there has been a movement to rename the master branch to main, in order to be more inclusive and avoid any negative connotations associated with the term "master."

GitHub, the largest Git hosting platform, has already adopted the main branch as the default name for new repositories. Many other Git hosting platforms and open-source projects are also following suit.

So, what is the difference between main and master?

Technically speaking, there is no difference. Both main and master are branches, and they can be used in the same way. However, there are some potential differences in how they are used and perceived.

For example, some people may feel more comfortable working on a main branch, as it is a more inclusive and modern name. Others may prefer to continue using the master branch, as it is the more traditional name.

Main & Master Branch

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

==>Git and GitHub are two different but complementary tools that are used by software developers. Git is a distributed version control system, while GitHub is a web-based hosting service for Git repositories.

Git allows developers to track changes to their code over time and collaborate with other developers on the same project. It does this by creating a local copy of the project's entire history on each developer's machine. This means that developers can continue to work on their code even if they don't have an internet connection.

GitHub is a web-based service that allows developers to share their Git repositories with others. It also provides a number of features that make it easy to collaborate on projects, such as code review, issue tracking, and pull requests.

Git - GitHub

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

==> To create a new repository on GitHub, follow these steps:

  • Go to GitHub.com: https://github.com/ and sign in to your account.
  • Click the + button in the top right corner of the page.
  • Select New repository.
  • Enter a name and description for your repository.
  • Choose whether you want your repository to be public or private.
  • Click Create repository.

Once you have created your repository, you can start adding files to it. You can do this by dragging and dropping files into the repository page, or by cloning the repository to your local machine and then adding files to the cloned repository.

Once you have added files to your repository, you can commit them and push them to GitHub. To do this, open a terminal window and navigate to the directory where you cloned your repository. Then, run the following commands:

  • git add .
  • git commit -m "Your commit message"
  • git push

This will commit your changes to the local repository and then push them to GitHub.

After you have pushed your changes to GitHub, your repository will be updated and the changes will be visible to anyone who has access to the repository.

Here is an example of how to create a new repository on GitHub using the command line:

This will create a new repository on GitHub named <your_repository_name> and push the initial commit to the main branch.

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

==>

  • Local repository

A local repository is a Git repository that is stored on your computer. It is a complete copy of the project's history, including all of the branches, commits, and tags.

  • Remote repository

A remote repository is a Git repository that is stored on a server. It is usually shared among team members, so that everyone can work on the same project and share their changes.

  • How to connect local to remote

To connect your local repository to a remote repository, you can use the following steps:

  1. Navigate to your local repository in a terminal.
  2. Run the following command to add the remote repository:

git remote add <remote-name> <remote-url>        

Replace <remote-name> with a name for the remote repository, and <remote-url> with the URL of the remote repository.

  1. Run the following command to fetch the changes from the remote repository:

git fetch <remote-name>        

  1. Run the following command to merge the changes from the remote repository into your local repository:

git merge <remote-name>/<branch-name>        

Replace <branch-name> with the name of the branch that you want to merge.

Once you have connected your local repository to a remote repository, you can easily share your changes with others by pushing your changes to the remote repository. To do this, run the following command:

git push <remote-name> <branch-name>        

Replace <remote-name> and <branch-name> with the same values as you used in the previous step.

Local Repository & Remote Repository

  • Example

To connect your local repository to a remote repository on GitHub, you would use the following steps:

  1. Navigate to your local repository in a terminal.
  2. Run the following command to add the remote repository:

git remote add origin https://github.com/<username>/<repository-name>.git        

Replace <username> with your GitHub username, and <repository-name> with the name of your GitHub repository.

  1. Run the following command to fetch the changes from the remote repository:

git fetch origin        

  1. Run the following command to merge the changes from the remote repository into your local repository:

git merge origin/main        

  1. To push your changes to the remote repository, run the following command:

git push origin main        

I'm confident that this article will help you to discover new insights and learn something about version control system.

#90daysofdevops#learning#devops#skill#tws#trainwithshubham#happylearning

Thank you:)

要查看或添加评论,请登录

Prakash Bohara的更多文章

社区洞察

其他会员也浏览了