# Day 12 - Task: Deep Dive in Git & GitHub for DevOps Engineers

# **🔹What is Git and why is it important?**

**Git** is a distributed version control system that allows multiple developers to work on a project simultaneously without overwriting each other's changes. It helps track changes in source code during software development, enabling collaboration, version control, and efficient management of code changes.

**Importance of Git:**

* **Version Control:** Keeps track of changes, allowing you to revert to previous versions if needed.
    
* **Collaboration:** Multiple developers can work on the same project simultaneously.
    
* **Branching:** Allows you to work on different features or fixes in isolation.
    
* **Backup::** Acts as a backup of your codebase.
    

# **🔹What is difference Between Main Branch and Master Branch?**

* Traditionally, **master** was the default branch name in Git repositories. However, many communities have moved to using **main** as the default branch name to be more inclusive and avoid potentially offensive terminology.
    
* Main Branch vs. Master Branch:
    
    * **Main Branch:** The new default branch name used in many modern repositories.
        
    * **Master Branch:** The traditional default branch name used in older repositories.
        
    
    The traditional default branch name used in older repositories.
    

# **🔹Can you explain the difference between Git and GitHub?**

* **Git** is a version control system, while **GitHub** is a web-based platform that uses Git for version control and adds collaboration features like pull requests, issue tracking, and project management.
    
    * Git:
        
        * Command-line tool.
            
        * Manages local repositories.
            
    * GitHub:
        
        * Hosting service for Git repositories.
            
        * Adds collaboration tools and user interfaces.
            

# **🔹How do you create a new repository on GitHub?**

1. Go to GitHub.
    
2. Click on the + icon in the top right corner.
    
3. Select New repository.
    
4. Enter a repository name (e.g., "DevOps").
    
5. Click Create repository.
    

# **🔹What is the difference between local & remote repositories? How to connect local to remote?**

* Local Repository:
    
    * Stored on your local machine.
        
    * Contains your working directory and Git database.
        
* Remote Repository:
    
    * Hosted on a server (e.g., GitHub).
        
    * Allows collaboration with other developers.
        
* Connecting Local to Remote:
    
    1. Initialize a local repository: `git init`
        
    2. Add a remote: `git remote add origin <remote_repository_URL>`
        

# **🔹Task-1:**

* Set your user name and email address, which will be associated with your commits.
    
    ```bash
    git config --global user.email "youremail@example.com"
    git config --global user.name "Your Name"
    ```
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486171130/b8bccb05-0ce5-4338-8d15-cc2e7a83d8c6.png align="center")
    
    # **🔹Task-2:**
    
    * Create a repository named "Devops" on GitHub
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749481190083/8dd54faf-8ce6-4d45-a1dc-003e9d684c2a.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749481205786/6015da89-634e-4aaf-8de8-199935f829b0.png align="center")
    
    * Connect your local repository to the repository on GitHub.
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486212445/3f3c40cc-3f15-4875-8645-738d8eaa8f8f.png align="center")
    
    * Create a new file in Devops/Git/Day-02.txt & add some content to it
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486244412/9802896f-2a90-4557-959f-8b0c118b8559.png align="center")
    
    * Push your local commits to the repository on GitHub
        
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486263397/2937c5c6-0490-456d-a8ce-48b6b2047ec1.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486278002/2e52c031-c817-4dd4-ab4a-06f618462974.png align="center")
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1749486300174/7597a6bf-46db-4f83-9159-f6a9f1e63eaa.png align="center")
    
    Thank you for Reading:)
