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

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

·

4 min read

Importance of Git

As we have seen in the last article about what is Git. We will deep dive into why it is important. Just to recap we need to remember the 3 keywords which are :

  • Version Control System (VCS)

  • Code management

  • Collaboration

Being a VCS it can be used to :

  • Revert to previous versions of the files if you make a mistake.

  • See what changes have been made to the files by different people.

  • Collaborate on projects with other people without overwriting each other's work.

Difference between Main branch and master branch

The main branch and master branch are essentially the same in Git.

They are both the default branch in a new repository, and they are both used to track the most recent and stable version of the codebase.

However, the main branch is becoming more common as a default branch name, as some people believe that the term "master" has negative connotations.

Difference between Git and Github

Git is a version control system, which means it helps you track changes made to your codebase over time. It allows you to create a local repository (or clone) of your project on your computer, make changes, commit those changes, and then share the updated code with others.

Think of Git as a tool for managing drafts of a document - you can work on it alone, then share it with others when you're ready.

GitHub, on the other hand, is a web-based platform where you can host your Git repositories. It provides features such as version control, issue tracking, and collaboration tools.

GitHub acts as an online storage space for your Git repositories, allowing you to access and manage them from anywhere, at any time.

Think of GitHub like a cloud-based file cabinet where you store all your important documents - you can access them whenever you need to, and invite others to collaborate on them.

Creating a new repository on Github

  1. Sign in to your GitHub account.

  2. Click on the "+" button in the top left corner of the dashboard.

  3. Select "New" and then click on "Repository".

  4. Enter a name for your repository and a short description.

  5. Choose a license for your repository.

  6. Click on the "Create repository" button.

  7. GitHub will create a new repository and take you to its page.

Difference between local and remote repository and connecting local to remote.

A local repository is a copy of a repository that is stored on your local machine, whereas a remote repository is a central location where data is stored and managed. In Git, a local repository is a copy of the entire repository that you have cloned from a remote repository. This allows you to work on the code locally before pushing your changes back to the remote repository.

A remote repository, on the other hand, is a central location where all the changes from multiple contributors are stored and managed. When you push your changes from your local repository to a remote repository, you are updating the central copy of the code with your changes.

To connect a local repository to a remote repository, you typically need to do the following :

  1. First, create a local repository by cloning a remote repository.

  2. Make changes to the code in your local repository.

  3. Commit your changes by creating a commit that describes the changes you made.

  4. Push your committed changes from your local repository to the remote repository using the git push command.

As we had pushed Day08 a file name solution.md on Github using the Personal Access Token you can follow the similar commands.

Tasks

Setting user name and email address

  1. Run the command git config --global user.name "Your Name" replacing "Your Name" with your actual name.

Run the command git config --global user.email "your_email@example.com" replacing "your_email@example.com" with your actual email address.

Create a repository named "Devops" on GitHub

As mentioned above the steps can be followed to create this repository on Github.

Connect your local repository to the repository on GitHub.

It can be done in the same way as it was done on Day08. Just the URL for Git push and Git pull should be changed. Github link using the (PAT) can be used.

Use the following commands

Creating a new file in Devops/Git/Day-02.txt & adding some content to it.

Push your local commits to the repository on GitHub.

This was a fun blog.I hope to see you in the next one.Happy coding!