# Day 9 Task: 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 code management and Version control system. Git allows developers to collaborate on projects by making it easy to merge changes made by multiple contributors. It also provides features such as branching and tagging, which make it easy to experiment with different versions of a project and track specific milestones.

**2) What is difference Between Main Branch and Master Branch?**

**The main branch — the one where all changes eventually get merged back into, and is called master.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679988649575/98728d9c-45d2-4882-b4cb-cb58cff70c1b.png align="center")

In essence, "main" and "master" branches are identical in functionality and usage. They both represent the primary branch of a Git repository where the latest changes are merged and from where new branches are typically created. The only difference is the name used for the primary branch.

In practical terms, the difference between the "main" and "master" branch is largely a matter of convention and preference. Some developers and organizations prefer to use "main" to refer to the default branch, while others continue to use "master".

**3) Can you explain the difference between Git and GitHub?**

Git is a distributed version control system that was created by Linus Torvalds in 2005. It is a command-line tool that allows developers to track changes to their code, collaborate with others, and revert to previous versions if necessary. With Git, developers can create local repositories on their computers and synchronize their changes with remote repositories hosted on different servers.

GitHub, on the other hand, is a web-based platform that provides hosting services for Git repositories. It was created in 2008 and is now owned by Microsoft. GitHub allows developers to store and manage their Git repositories on remote servers and provides a graphical user interface (GUI) for performing Git operations. It also offers additional features such as bug tracking, issue management, pull requests, and code reviews.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679989175484/00cb3c83-c63b-4711-bcfe-1d806384dc0e.png align="center")

**4) How do you create a new repository on GitHub?**

1. Log in to your GitHub account.
    
2. Click on the "+" icon in the top right corner of the page.
    
3. Select "New repository" from the dropdown menu.
    
4. Enter a name for your repository.
    
5. Add a description if you like (optional).
    
6. Choose whether you want the repository to be public or private.
    
7. Select the checkbox to "Initialize this repository with a README" (optional).
    
8. Choose a license if you like (optional).
    
9. Click "Create repository".
    

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

Git local repository is the one on which we will make local changes, typically this local repository is on our computer.

Git remote repositories are hosted on a server that is accessible for all team members. 

Task-1:

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

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679989715929/3d37cdf0-bee4-4da5-9120-4872f4420e5d.png align="center")

task-2:

\- **Create a repository named "Devops" on GitHub.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679990053772/d7739092-450e-4224-8eaf-a4c4d5ebcf67.png align="center")

\- **Connect your local repository to the repository on GitHub.**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679990509660/1b2beb27-47ec-49d1-b44d-54d3da9365f0.png align="center")

```bash
git remote add origin <URL>
```

\- **Create a new file in Devops/Git/Day-02.txt & add some content to it.**

```bash
git clone
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679991391297/aaf5d294-ac1d-4730-a4a7-49597a8118f8.png align="center")

**Create a file in Devops/Git:**

```bash
git status
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679992309189/04b00995-30a6-4d7b-a08a-c973a9c89046.png align="center")

```bash
git commit -m "message"
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679992663141/9e14ed18-c16f-4147-a4b0-5aaf255334c1.png align="center")

\- **Push your local commits to the repository on GitHub**.

Git push : The git push command is used to upload local repository content to a remote repository.

```bash
git push -u origin
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679994146604/2c7eaef4-428c-45d4-8444-145fbfd38f6b.png align="center")

* For the Password generate a token from GitHub.
    

Check it on GitHub Account

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1679994624928/a41308f2-d6bc-49b8-aced-d2c07a237738.png align="center")

Thank You for reading this Article.
