# 🔥Day8#90daysDevops Challenge

## Basic Git & GitHub for DevOps Engineers.

### 💎 **Task**

**💎** Create a new repository on GitHub and clone it to your local machine.

💎 Make some changes to a file in the repository and commit them to the repository using Git.

💎 Push the changes back to the repository on GitHub.

---

### 💎 Create a new repository on GitHub and clone it to your local machine.

**🔸 Create a new repository on GitHub**

1. First, go to https://github.com/ and sign up GitHub account using the details.
    
2. Click on the <mark>+ icon</mark> which is in up right corner and create a new repository on GitHub
    
3. Give the name of the Repository as I created "**git-practice1**"
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692976601625/69d55e31-5cbe-4cea-a180-30628ac2e8fb.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1692976863089/c1fbb273-1b65-4ad0-a9a3-da7ac6e36cf2.png align="center")

**🔸 To clone this repository to your local machine use the command.**

1. First I created a directory on my local machine named "**git-task**" and cloned the GitHub repository to that directory.
    
    ![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693152683534/79d238cf-c705-43d2-9ac8-4c9d1aabc282.png align="center")
    
2. Copy this URL by clicking on the code icon you will get the link.
    

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1696008787731/b6bd5aa6-f5b7-41b2-bd29-ebc5d5cf22da.png align="center")

1. Copy that link and paste it into the command for cloning that repository to your local machine.
    

```plaintext
git clone <url>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693136730210/3631da7a-2eb6-49c9-9fa5-e06c7aafce55.png align="center")

---

### 💎 Make some changes to a file in the repository and commit them to the repository using Git.

🔸 In the present file, only the following commands are present.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693137072425/a2c4fe1c-d737-4294-9295-929095dac4e6.png align="center")

🔸 Added a few more commands to that file.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693137163656/fc3e58c9-bf61-4ef4-b209-dd5187f16437.png align="center")

🔸 For committing them to the repository use the **git add** command to add the changes and then commit them

```plaintext
#for adding the changes
git add

#for commiting the changes
git commit -m "commit message"
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693137296863/3bad1fb1-facf-4dbe-a9c4-f9e355bf2227.png align="center")

---

### 💎 **Push the changes back to the repository on GitHub.**

🔸 Before pushing the changes to GitHub add and commit the changes locally using this command

```plaintext
# To add the changes
git add .


# To commit the changes
git commit -m "commit message"
```

🔸 After that, the repository is ready to push on GitHub using the following commands

```plaintext
#To change remote url
git remote -v 

# To push local repository to public
git remote set-url [--push] <name> <newurl> [<oldurl>]

# To add new url
git remote set-url --add <name> <newurl> 

# To delete old url
git remote set-url --delete <name> <newurl>
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693137373538/d795b8cf-484b-491c-9fb3-9e73c7ddee15.png align="center")

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1693152973418/c2ed7e6d-00d7-47e9-afaf-1347dc0c64fc.png align="center")

---
