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

## Difference between the main branch and the master branch?

***Master Branch:-***

When the developer created a repository and many branches are available. But the final and accurate code is kept at a single branch which is the ***master*** ***branch***. In this master branch, not everyone makes changes only correct code is taken from other branches and pushed into the master branch. In git by default branch is the ***master branch***.

***Main Branch***:- The meaning of master and the main branch is the same but it uses master and GitHub uses main that's it. Because in October 2020, the ***GitHub*** company ***changed the term from “master”*** to ***“main”***.

## Difference between Git and Github?

| [**S.No**](http://S.No)**.** | **Git** | **GitHub** |
| --- | --- | --- |
| 1. | Git is software. | GitHub is a service. |
| 2. | Git is a command-line tool | GitHub is a graphical user interface |
| 3. | Git is installed locally on the system | GitHub is hosted on the web |
| 4. | Git is maintained by Linux. | GitHub is maintained by Microsoft. |
| 5. | Git is focused on version control and code sharing. | GitHub is focused on centralized source code hosting. |
| 6. | Git is a version control system to manage source code history. | GitHub is a hosting service for Git repositories. |
| 7. | Git was first released in 2005. | GitHub was launched in 2008. |
| 8. | Git has no user management feature. | GitHub has a built-in user management feature. |
| 9. | Git is open-source licensed. | GitHub includes a free tier and a pay-for-use tier. |
| 10. | Git has minimal external tool configuration. | GitHub has an active marketplace for tool integration. |
| 11. | Git provides a Desktop interface named Git Gui. | GitHub provides a Desktop interface named GitHub Desktop. |
| 12. | Git competes with CVS, Azure DevOps Server, Subversion, Mercurial, etc. | GitHub competes with GitLab, Bit Bucket, AWS Code Commit, etc. |

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

After you create your **GitHub** account, click on the **+** button and select a new repository. After that, type the repository name and add a simple description. It will create an empty public repository.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682078314301/173aadc5-a253-448d-ba82-b676f5384488.png align="center")

After creating the repository on **GitHub,** it will provide a detailed guide on how to clone, add remote, and initialize a Git project.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682078492898/ea16bc0d-d05f-41ce-977e-22bf1b39313a.png align="center")

## Difference between local and remote repositories? how to connect locally to the remote repository?

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682078742859/c9efd25a-da0d-43b5-b8ea-a3cd2fcf8263.png align="center")

A local repository is a copy of a Git repository that is stored on your local computer, while a remote repository is a copy of the same repository that is hosted on a remote server, such as GitHub

## task-1:

* Set your user name and email address, which will be associated with your commits.
    
    To set a user name.
    
    `sudo git config --global` [`user.name`](http://user.name) `"Your Name"`
    
    To set email id.
    
    `sudo git config --global` [`user.email`](http://user.email) `"`[`your.email@example.com`](mailto:your.email@example.com)`"`
    
    verify user name and email.
    
    `sudo git config --list`
    
* ***git config --the list*** is used to show the list of usernames and emails.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682083890226/4c11ca9a-18c8-46df-8a92-be11d349841b.png align="center")

### task-2:

perform push and pull and transfer repository from local to GitHub and GitHub to local git.

following are the steps follow as it is:-

1. create the folder devops-eng-batch. eg. ***mkdir DevOps-eng-batch***
    
2. Go into a folder. ***cd devops-eng-batch***
    
3. Create a file. ***touch hello.txt***
    
4. now use the git init command.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682406705776/a901d6a7-a7d3-46c6-8e60-c1e1bbf9c308.png align="center")

1. provide a username and email id compulsory otherwise, it takes both by default.  
    `sudo git config --global` [`user.name`](http://user.name) `"Your Name"`  
    `sudo git config --global` [`user.email`](http://user.email) `"`[`your.email@example.com`](mailto:your.email@example.com)`"`
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682083890226/4c11ca9a-18c8-46df-8a92-be11d349841b.png align="left")
    
2. Add file to git.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682406971445/1fbdb07f-6ae5-4658-b147-3839ee36959f.png align="center")
    
    When you add a file it goes into the staging state.
    
3. Commit the file. When you commit the file it is stored in the git folder.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682407083415/d65c62ed-bde9-49c8-ac33-8a05a6e34d9f.png align="center")
    
4. So the file is added to the local Git folder. Now we want to send this to our GitHub repository. So before that create a repository in Github of "devops-zero-to-hero-english".
    
5. (For my reference, I have created one more file but you can carry it with the previous file). Again i have committed my\_test\_file.txt to local Git. Now, I have transferred this file to GitHub at "devops-zero-to-hero-english". To create a token **Go to settings-&gt;Devloper Settings-&gt;personal Access token-&gt;Token classic-&gt;Generate new token-&gt;Click on all repositories -&gt;Generate Token.** Copy that token.
    
6. Use the command:- **git remote set-url origin** [https://ghp\_vyOBoMIgUoAYaetpn0VcJzwIg64duZ3TdEZW@github.com/VibhutePooja283/devops-zero-to-hero-english.git](https://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@github.com/VibhutePooja283/devops-zero-to-hero-english.git)  
    So with the help of this, there is no need to provide a username or password. But we provide the authenticated token to them.  
    Format of URL:- ***git remote set-url origin http://token@github.com/writepart after HTTPS.*** You will get this format by ***git remote -v.***
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408289192/c4652677-d4b4-4c02-b400-143170f26265.png align="center")
    
7. Then push your file to the GitHub repository. ***git push origin main***
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408369802/ab75d56e-895c-42c8-82e0-365fdd49b37f.png align="center")
    
    To see the following image our my\_test\_file.txt comes from Git to Github.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408497898/89f362f0-1368-43cc-82ea-509c24bd5380.png align="center")
    
      
    
8. Now Create Another File my\_remote\_file.txt and pull it from Github to Git, ***git pulls the origin main***  
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408647572/18a87331-686a-4bc1-8376-c6e90371ea4d.png align="center")

You can check file is coming in the git local folder by ***ls*** command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408776714/f56a55bf-c4e8-40fa-b5e1-40c6f86b301d.png align="center")

You can check to contain via the ***cat*** command.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1682408873294/4d3c31a9-9fe1-4f8b-95fb-210d27e9a76e.png align="center")
