# GitHub for DevOps Engineers

👋Hi Everyone,

Welcome to **Day 08 (Part-2)** of the **#90DaysofDevops** learning journey. In this article, we will cover about GithHub and its importance, how to create a repository, and clone a repository.

## 🔶 What is Github?

GitHub ***is a Git repository hosting service***.

The version control system Git is hosted on the internet via GitHub. Developers, DevOps teams, and businesses of all sizes use it extensively to manage their source code repositories, collaborate on code with others, and create software applications.

**Here are a few reasons why GitHub is a popular choice for version control:**

### 🔸 Collaboration:

GitHub makes it simple to work on code with others, no matter where they are in the world. It offers tools like pull requests, code reviews, and problem tracking that make team collaboration easier and more productive.

### 🔸 **Community:**

GitHub has a large and active community of developers, who share code, contribute to open-source projects, and offer support and guidance to others.

### 🔸 **Integration:**

GitHub integrates with many other programs and services, including Jenkins, Travis CI, Docker, and Amazon. As a result, adding GitHub to your current DevOps operations is simple.

### 🔸 **Accessibility:**

Because GitHub is accessible from anywhere with an internet connection, it is simple to manage and collaborate on code from anywhere in the world.

### 🔸**Security:**

GitHub offers a variety of security features, such as two-factor authentication, encrypted connections, and granular access controls. This helps to ensure that your code and data are secure and protected.

### 🔸**Open source:**

GitHub is an open-source platform, which means that its code is freely available for others to use and contribute to. This has contributed to the popularity of GitHub among open-source developers and communities.

## 🔶 **Create a new repository on GitHub and clone it to your local machine**

To create a new repository in GitHub, follow these steps:

1. Log in to your GitHub account and click the "+" sign in the upper right-hand corner of the dashboard.
    
2. Select "New repository" from the dropdown menu.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680716067454/7461c438-47eb-420d-afab-1d4d3a30e777.png align="center")
    
3. Choose a name for your repository.
    
    For example, now we will create a repository name "Python\_Notes"
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680718852148/a1375099-b608-4499-b64a-5c92f4171955.png align="center")
    
4. Optionally, add a description for your repository.
    
    In the description box "Python study material for beginners"
    
5. Choose whether you want your repository to be public or private. Public repositories are visible to everyone, while private repositories require authentication to access.
    
6. Select whether you want to initialize your repository with a README file, which is a good practice to give an overview of your project.
    
7. Choose a license for your repository if you wish to make it available for reuse by others.
    
8. Click the "Create repository" button.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680718760221/be6729f8-6296-4fc9-8b5e-1db01a9f9443.png align="center")
    

Once you have created your repository, you can start adding files, making commits, and pushing changes to the repository. You can also invite collaborators to work on the repository with you, manage access permissions, and track issues and pull requests.

So, successfully created the **"Python\_Notes"** repository.

select Create a New file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680718993706/9bbf4605-7285-48cd-8496-908061bca1e3.png align="center")

So, we will create the first Python Program file i.e. **"welcome.py"**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680718530260/af45e1d4-acba-41c4-89a6-254697f96fd2.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680721770173/0106e5cb-3ac9-4324-9af4-c9d9696b68a6.png align="center")

click on "**Commit new file"** with a commit message "first commit in the welcome file"

check the file "**welcome.py"** created in the **"Python\_Notes"** repository.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680720221305/a075a24a-2af6-40e8-91dd-1c4ae4dc83e4.png align="center")

### 🔶 **Clone a GitHub Repository**

Cloning a remote in Git creates a local version of that repository on your machine, allowing you to explore in a safe space without impacting the source code.

Cloning also establishes a connection between the local repository on your machine and the remote repository, allowing push and pull actions with the remote project.

Go to your repository on GitHub. In the top right above the list of files, open the **Clone or Download** drop-down menu. Copy the **URL for cloning over HTTPS**.

next step Check if the repository has been created and copy the GitHub repository(HTTPS) URL

[https://github.com/CloudDevopsJourney/Python\_Notes.git](https://github.com/CloudDevopsJourney/Python_Notes.git)

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680717260936/6da8cbae-3476-4716-8255-63c45cc67c25.png align="center")

Open GitBash Terminal **Cloning an Existing Repository from GitHub** to your local Machine.

If you want to get a copy of an existing Git repository — for example, a project you’d like to contribute to — the command you need is `git clone`.

```plaintext
git clone https://github.com/CloudDevopsJourney/Python_Notes.git
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680723089282/2d50da15-f9dd-4d8a-a7da-7f445bcbae57.png align="center")

Now you can see on your local machine cloned repository.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680723437648/f302425f-e9a3-4a4e-9680-c022cd27e473.png align="center")

Open the GitBash terminal, and run the command `py welcome.py` file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680725376300/6d498d6a-4527-40be-9ca1-19e26f2ccd38.png align="center")

### 🔶 Push the changes back to the repository on GitHub

Now edit `py welcome.py` file and add a new line in the file. with the help of the vi editor.

vi editor will open and press the `Esc` button --&gt;press `i` for insert Mode--&gt; modify file --&gt; press `Esc` then`:wq!` and press `Enter`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680725111706/01df5675-2011-46bf-b630-72c090ea4eab.png align="center")

After modifying the file content once again run the command `py welcome.py`

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680726534936/cdaa4eda-7189-4937-8b59-5ce1e3d4c4a7.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680726813807/74ffaf00-1344-4af5-8fc2-e984dc7e8b8f.png align="center")

### 🔶 Push the changes back to the repository on GitHub

**A remote repository (often called a remote), is a Git repository hosted on the Internet or some other network.**

First, execute the `git remote –v` command to check available remote URL

```plaintext
git remote -v
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680727637227/71359b0f-1ca8-4710-8033-fba050467bd9.png align="center")

1. Type `git push` to push the changes to the remote repository on GitHub.
    
    You can use `git push origin` or `git push origin main`
    
    (Note: here `main` is the branch name)
    
    ```plaintext
    git push origin
    ```
    
2. Enter your GitHub username and password if prompted.
    
3. Verify that the changes are pushed to the remote repository by visiting your repository's page on GitHub.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1680851928421/edf39b27-0edd-4ead-b09a-ab4bedb9b569.png align="center")
    

It's important to note that if there are conflicts between your local repository and the remote repository on GitHub, you may need to resolve those conflicts before pushing your changes. Also, make sure that you have the necessary permissions to push changes to the repository.

### **🎉 Task Done👍 Day 08 of #90daysofdevops 💯**

In this article, we have covered the **Day 08 (Part-2)** task and learned about GitHub and its importance.

You can store a variety of projects in GitHub repositories, including open source projects, you can share code to make better, more reliable software.

Overall, GitHub is a powerful and flexible platform that provides a range of features and benefits for version control and collaboration. Its popularity and community make it an attractive choice for developers and organizations of all sizes.

***If you enjoyed this article please like it and share it with your friends and colleagues!***

**Thank you for reading🤓**
