# Deep Dive in Git & GitHub for DevOps Engineers part 2 #Day 9

# **Task1:**

Set your user name and email address, which will be associated with your commits.

First, install git in your instance

```plaintext
sudo apt-get install git init
```

then you can check that git is installed or not with the help of this command

```plaintext
git  --version
```

![](https://miro.medium.com/v2/resize:fit:875/1*wVJuRrfFzMVcoRvZDgSMGg.png align="left")

\&gt; Now create a username and email address

```plaintext
git config --global user.name "Enteryourname"
git config --global user.email "Enteryouremail"
```

![](https://miro.medium.com/v2/resize:fit:875/1*Yw2UoGwFfwNLFvclIrYH2Q.png align="left")

To check username and password use this command

```plaintext
git config --list
```

![](https://miro.medium.com/v2/resize:fit:875/1*8c3IsqWZ7LbrEGV7Kw_Z9Q.png align="left")

# **Task2:**

Create a repository named “Devops” on GitHub.

now go into your git hub account

Go to the dashboard and click on the “New” button to create the repository.

it will look like this

![](https://miro.medium.com/v2/resize:fit:875/1*jJV5ei2t2rp7OPqbVG2qLQ.png align="left")

Connect your local repository to the repository on GitHub.

first of all, go into the GitHub dashboard then open your repo.

then click on code this is will in the right-side corner it will look like this

![](https://miro.medium.com/v2/resize:fit:875/1*m-Tq-48uBnwQ9Vkyf-FkjA.png align="left")

Then copy your ssh- key, then open your terminal and type this command to connect your local repository to the GitHub repository

```plaintext
sudo git clone <ssh-key-url>
```

![](https://miro.medium.com/v2/resize:fit:875/1*5DtjIQShvHEreDh7lJnyMQ.png align="left")

Create a new file in Devops/Git/Day-02.txt & add some content to it

Now go to the DevOps folder/directory

```plaintext
cd DevOps/
```

Now create another folder/directory and create a text file and some content inside the file.

```plaintext
mkdir Git
```

```plaintext
cd Git/
vi Day-02.txt
welcome to DevOps
esc
:wq
```

to check the file status use the command “git status” With the help of this command you can file is committed or not

```plaintext
git status
```

![](https://miro.medium.com/v2/resize:fit:875/1*B-PARKC3meFX64lrIiAZQQ.png align="left")

```plaintext
git add .
```

![](https://miro.medium.com/v2/resize:fit:875/1*Lg6PpF-_eDPkLK53B7QkyA.png align="left")

```plaintext
git status
```

![](https://miro.medium.com/v2/resize:fit:875/1*Lg6PpF-_eDPkLK53B7QkyA.png align="left")

After the check status of the file the commit your file this commit will show on your GitHub account there will show also the user name who commit to that

```plaintext
git commit -m "this is first commit"
```

![](https://miro.medium.com/v2/resize:fit:875/1*oTlNL4-wkj31TGm3Mn-9iQ.png align="left")

```plaintext
git status
```

![](https://miro.medium.com/v2/resize:fit:875/1*vyqE1yE_iyPNsQb_80IJOA.png align="left")

you can check the file comment with the help of “git log “ where you will see your commit id 40alphanumeric type git log and paste your commit your will comment

```plaintext
git log
```

![](https://miro.medium.com/v2/resize:fit:875/1*vyqE1yE_iyPNsQb_80IJOA.png align="left")

now push your code file on your remote account use of this command ‘’git push origin main”

```plaintext
git push origin main
```

![](https://miro.medium.com/v2/resize:fit:875/1*2DUkOvBY_NbW-kB97YUOtg.png align="left")

To check that your file is now present on your “GitHub account go to the account

and click on your repo. you will your repo name like “DevOps” Click on the you will another folder “Git”.

![](https://miro.medium.com/v2/resize:fit:875/1*siOhcdQjZyWpQEAlvMNzAQ.png align="left")

After clicking on “Git” you will see a file name like “Day-02.txt” Click on that now there will show you the file and the file comment on the top.

![](https://miro.medium.com/v2/resize:fit:875/1*xFhRkeILNR5BQbm9hmEW_Q.png align="left")

![](https://miro.medium.com/v2/resize:fit:875/1*kLZC2oqFsvLwbDzIdu7kiQ.png align="left")
