Day 9 Task: Deep Dive in Git & GitHub for DevOps Engineers

Vishugoyal
6 min readFeb 16, 2023

90DaysOfDevOps

What is Git and why is it important?

Git is a version control system that helps developers keep track of changes to their code over time. It allows multiple people to work on the same project and merge their changes together in a way that avoids conflicts and preserves the history of changes.

Git is important because it provides a way for developers to collaborate effectively, work on multiple branches of code simultaneously, and easily revert changes if something goes wrong. It also makes it easier to review and approve changes before they are merged into the main codebase, which can improve the overall quality and stability of the project.

In short, Git is a powerful tool for managing code that helps developers work more efficiently and collaboratively, which is essential for modern software development.

What is difference Between Main Branch and Master Branch ?

In Git, “main” and “master” are just two different names that can be used for the default branch in a Git repository. Historically, “master” has been the more commonly used name, but in recent years, there has been a push to switch to “main” .

In terms of Git, “main” and “master” are essentially identical. They both serve as the default branch in a repository and can be used as the basis for creating new branches and merging changes. Some Git hosting services, such as GitHub, now default to using “main” instead of “master” for new repositories, but both names are still widely used in practice.

Can you explain the difference between Git and GitHub?

Git is a distributed version control system that is used to manage changes to source code over time. It allows multiple people to collaborate on a project and track changes made by each person. With Git, developers can create new branches, make changes to code, and merge their changes with other people’s changes in a way that avoids conflicts and preserves the history of changes.

GitHub, on the other hand, is a web-based platform that provides a hosting service for Git repositories. It allows developers to store their code on GitHub’s servers and collaborate with others using Git. With GitHub, developers can create and manage repositories, make pull requests to suggest changes to others’ code, and review and approve changes made by others.

In other words, Git is the underlying technology that enables version control, while GitHub is a tool that provides a platform for storing and sharing Git repositories. While Git can be used without GitHub, using GitHub makes it easier to collaborate with others on a project, keep track of changes, and manage the development process.

How do you create a new repository on GitHub?

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

  1. Go to the GitHub website (https://github.com/) and log in to your account.
  2. Click on the “New” button on the left side of the page, next to the list of your repositories.
  3. Enter a name for your repository in the “Repository name” field. This name should be unique and descriptive of your project.
  4. Optionally, add a description of your repository in the “Description” field.
  5. Choose whether you want your repository to be public or private. Public repositories can be viewed and cloned by anyone, while private repositories are only visible to collaborators you specify.
  6. Select the option to “Initialize this repository with a README” if you want to create a new file that describes your project.
  7. Add any additional files or folders you want to include in your repository by using the “Add file” button.
  8. Once you’re done, click the “Create repository” button at the bottom of the page.

Your new repository should now be created and ready to use. You can clone the repository to your local machine, add files, and make changes using Git, and push your changes back up to GitHub.

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

In Git, a local repository is the version of the repository that exists on your local machine, while a remote repository is a version of the repository that exists on a remote server, such as GitHub or GitLab. The local repository is the copy of the repository that you work on and make changes to, while the remote repository is the copy that others can access and collaborate on.

To connect a local repository to a remote repository, you need to “push” your local changes to the remote server.

  1. Create a new repository on the remote server, such as GitHub or GitLab.
  2. Clone the remote repository to your local machine using the “git clone” command.
  3. Make changes to the files in your local repository as needed.
  4. Use the “git add” command to stage the changes you want to commit.
  5. Use the “git commit” command to create a new commit with your changes.
  6. Use the “git push” command to push your changes to the remote repository.

The “git push” command sends the changes you’ve made in your local repository to the remote repository, updating it with your changes. You may need to authenticate yourself with your remote repository using your username and password or SSH keys before you can push your changes.

TASKS (1) :

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

git config — global user.name “Your Name”

git config — global user.email “your.email@example.com”

TASKS (2) :

  • Create a repository named “Devops” on GitHub
  • Connect your local repository to the repository on GitHub.
  • Create a new file in Devops/Git/Day-02.txt & add some content to it
  • Push your local commits to the repository on GitHub

Step 1 → Create a new repo on GitHub

After created a new repo just copy the https path for clone the repo to the local repository to make it sync with the local one.

Check the status of the new folder in the local machine

Just clone the remote repo to the local folder then move inside the repo folder and check the status again.

Create a new file so it will add to the remote repository from the local repo.

By using the Notepad command you can create a notepad file in window and then check the status, It shows that something is untracked file. Then you can add that file and commit it after commit it.

First, Check the repository repo status.

Now, Push the local test.txt file to the remote.

Now, you have got a new file to the remote reposity i.e. test.txt.

Task Completed → Local commits pushed to the remote repository.

Thank you for giving your precious time for reading this blog/article and also follow me on Vishu Goyal for more such blogs/articles also thanks a lot for keeping your calm and reading till the end. I hope this article helped you :) Happy coding!

You can also mail me at vishugoyal247@gmail.com

--

--

Vishugoyal

I am pursiing B-tech. and also very fond of learning new technology under the guidance of Vimal Daga sir (World Record Holder).