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

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

What is Git and why is it important?

Git is a free, open-source distributed version-controlling system that enables developers to manage and track changes to the source code.

Importance of Git

  1. Effective collaboration: Developers can work independently on different parts of the code and then merge their changes when they're ready.

  2. Version control: Git helps to manage multiple versions of a source code and if something goes wrong developers can easily revert to the previous version of the source code.

  3. Branching: branching is an essential feature of git where developers create branches of their code and work on them independently without affecting the main branch.

What is the difference Between Main Branch and Master Branch?

Both Main and Master are the default branches when you create a repository. When you create a branch in GitHub by default it is set to Main as master has a negative connotation that resembles the master-slave concept.

Can you explain the difference between Git and GitHub?

Git is a distributed version control system that allows you to track changes in your files which can be stored locally.

On the other hand, GitHub is a web-based platform that stores the entire source code of the project remotely.

How do you create a new repository on GitHub?

  • Login/ Sign Up to your GitHub account

  • Click on the new repository option.

  • Enter the name of your repository based on your choice and add a description to it.

  • Choose the Visibility to public /private as per your requirement.

  • Add a README file.

  • Click on Create button and a new repository is created.

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 the developer's local machine and contains all the files that have been committed to it.

A remote repository on the other hand is a git repository that is stored in the remote server and can be accessed by all the project members over the Internet.

Steps to connect local to remote

1 . Initialize your local repository in the terminal by using the command git init and .git folder will be created.

2. Add files to your local repository and move them to the staging area with the command git add . and Commit the files that you've staged in your local repository by git commit -m "commit message"

3. Log in to your Github account and copy the URL of the remote repository

4. Add the url in your local repository using the command git remote add origin <url>

5. Push the changes to the remote repository using the command git push origin master (or main )

Hence, a connection is established between the local and remote repository and all the changes are pushed to the remote repository.

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

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.

First, add the file to the staging area by git add. command and then Commit it using git commit -m "message" command.

Then push the changes to the GitHub repository using git push origin main command.

  • \>>>>>>>>>>>>> Thank you for reading this article! :-) >>>>>>>>>>>>>