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

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

What is Git and why is it important ?

Git is a version control system used for software development. It allows developers to track changes, collaborate on code, and revert to previous versions if needed. Git's branching and merging features enable multiple developers to work on the same codebase simultaneously. It's important in modern software development because it provides a reliable and robust way to manage code and track changes over time.

What is the difference Between Main Branch and Master Branch?

There is no functional difference between the "Main" and "Master" branch in Git. Some organizations are transitioning to use "Main" instead of "Master" to avoid any connotations of slavery or racism associated with the term "Master".

The difference between Git and GitHub?

Git is a version control system that allows developers to track changes to their codebase, collaborate with others, and manage different versions of their code. GitHub is a web-based platform that provides hosting for Git repositories, along with additional features like issue tracking, project management, and social coding capabilities.

How do you create a new repository on GitHub?

To create a new repository on GitHub, login to your account, click the "+" icon in the top-right corner, and select "New repository". Then, follow the prompts to configure your repository.

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

A local repository is a Git repository that is stored on your local machine, while a remote repository is a Git repository that is hosted on a remote server or platform, such as GitHub. The key difference between the two is that a local repository is only accessible on your local machine, while a remote repository can be accessed by anyone with the appropriate permissions.

To connect a local repository to a remote repository, you can use the "git remote add" command, followed by the URL of the remote repository. For example, if you wanted to connect a local repository to a GitHub repository, you would run the following command:

git remote add origin github.com/your-username/your-repository.git

Once you have connected your local repository to a remote repository, you can push your local changes to the remote repository using the "git push" command. Similarly, you can pull changes from the remote repository to your local repository using the "git pull" command.

Tasks :

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

You can set your username and email address in Git using the following commands:

git config --global user.name "Your Name"

git config --global user.email ""

This will set your username and email address globally for all Git repositories on your machine. If you want to set them only for a specific repository, you can remove the "--global" flag and run the commands inside the repository's directory.

2) Create a repository named "Devops-batch-3" on GitHub

  • In the upper-right corner of any page, use the drop-down menu, and select New repository.

  • Type a short, memorable name for your repository

  • Optionally, add a description of your repository

  • Choose a repository visibility

  • Select Initialize this repository with a README

  • Click Create Repository.

3) Connect your local repository to the repository on GitHub

command : git clone github.com/cloudlearningguy/devops-batch-3...

4) Create a new file in Devops-batch-3/test.txt & add some content to it

5) Push your local commits to the repository on GitHub