# Day12 of #90DaysOfDevOps

1. **What is Git and why is it important?**
    
    Git is a powerful version control system. Think of it as a tool that helps you keep track of changes you make to files over time. Imagine you’re writing a book and you want to save every version of it, so you can always go back to any previous version whenever you want. Git does exactly that but for code and any other type of file.
    
2. **What is the difference between Main Branch and Master Branch?**
    
    The default branch created locally in git is known as "master", while the default branch created in GitHub is known as "main".
    
    Historically, the primary or the default branch for Git versions was named as "master".
    
3. **Explain the difference between Git and GitHub?**
    
    **Git:-** Git is Command-Line Interface tool (CLI). It is free, open-source and Distributed Version Control System (DVCS), that tracks the changes in any set of file.
    
    **GitHub:-** GitHub is Graphical User Interface tool (GUI). GitHub is a web-based hosting service for git repositories. GitHub is more user-friendly, repositories are open here so that developers can contribute to one another's code.
    
4. **How do you create a new repository on GitHub?**
    
    * **Sign in to GitHub: Open** your web browser and go to [**GitHub**](https://github.com/). Sign in to your GitHub account.
        
    * **Go to Your Profile: Cli**ck on your profile icon at the top right corner of the screen and select `Your repositories` from the dropdown menu.
        
    * **Create a New Repositor**[**y**](https://github.com/)**:** On the `Your repositories` page, click the green `New` button on the right-hand side.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729055838721/970751bd-9125-4f71-9ba5-1e10b30a2857.png align="center")
        
    * **Fill in Repositor**[**y Deta**](https://github.com/)**ils:**
        
        * Enter a name for your **r**epository in the `Repository name` field.
            
        * Optionally, add a description to describe your project.
            
        * Choose between making the repository public or private.
            
        * Select Initialize this repository with a README if you want to start with a README file.
            
5. **What is the difference between a local & remote repository? How to connect local to remote?**
    
    **Local repository:** A local repository is a copy of the entire project’s history and codebase that resides on a developer’s machine. It allows developers to work offline, experiment with different ideas, and maintain a private workflow.
    
    **Remote Repository:** A remote repository is a central shared repository hosted on a server, typically accessible over the internet. Examples are GitHub, GitLab, or Bitbucket.
    
    **Connect your local repository to remote repository**
    
    * **Make a repository on GitHub (remote) as we made above**
        
    * **Initialize an empty git repository:**
        
        To connect your local repository to a remote repository, first create a repository on GitHub (remote) as described above. Then, initialize an empty Git repository on your local machine by using the following command:
        
        ```bash
        git init
        ```
        
    
    * Add the remote repository URL:
        
        ```bash
        git remote add origin <remote_repo_URL>
        ```
        
    
    * **Push to remote:**
        
    
    ```bash
        git push origin main
    ```
    

## **Tasks**

### Task 1:

* Set your user name and email address, which will be associated with your commits.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729057583956/d1d31851-36a6-4d6b-bed0-3e13d9575a78.png align="center")
    
    ### Task 2:
    
    * Create a repository named "DevOps" on GitHub.
        
        ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729057945099/4c57a8d9-335d-4397-9509-a205b4213706.png align="center")
        
        * Connect your local repository to the repository on GitHub.
            
            ```bash
            git remote add origin <remote_repo_URL>
            git remote -v
            ```
            
            ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729059092956/672f4ae3-aebc-4c2e-99af-5ec0c4f33489.png align="left")
            
            * Create a new file in Devops/Git/Day-02.txt add some content to the file.
                
                ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1729059869700/1fc76f3e-a353-4f5b-be71-b9ea3ff47fd0.png align="center")
                
            * Push your local commits to the repository on GitHub.
                
                To push your local commits to the repository on GitHub, follow these steps:
                
                1. **Open your terminal** and navigate to the local repository directory.
                    
                2. **Add changes to the staging area** (if not already done):
                    
                    ```bash
                    git add .
                    ```
                    
                3. **Commit your changes** with a message:
                    
                    ```bash
                    git commit -m "Your commit message"
                    ```
                    
                4. **Push your commits** to the remote repository on GitHub:
                    
                    ```bash
                    git push origin main
                    ```
                    
                    Replace `main` with the name of your branch if it's different.
                    
                
                Make sure you have already connected your local repository to the remote repository on GitHub using the `git remote add origin <repository-url>` command.
                
                Stay tuned for more updates on my DevOps journey! 📅
                
                Feel free to reach out to me if you have any questions or need any more help. Let’s connect, learn, and succeed together!
                
                Happy Learning!😊
