# Push your first commit to Github

# Creating a Github repository

![rubaitul-azad-HLQDfaJUTVI-unsplash.jpg](https://cdn.hashnode.com/res/hashnode/image/upload/v1655544813725/GoAnSDfEL.jpg align="left")
This tutorial assumes you have Git installed in your system. Download it from [here](https://git-scm.com/downloads)

# Sign in to Github
Create a repository called ```first-commit```.

![createrepo.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655480224607/tjCV2U0SE.PNG align="left")
Scroll down and click on create to create the repository

Your next screen be similar to:

![createrepo2.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655480365268/5FX9sT5Ds.PNG align="left")

# Create a folder
On your desktop called  ```first-commit```.
Open the folder in a terminal. You can use either right-click and select  ```Git Bash``` or  type cmd on the address bar and press enter. It opens the windows command prompt.   

![openinterminal.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481121562/sjgeuOJH5.PNG align="left")

#. Initialize repository:
 Initialize an empty git repository using
  ```
git init
```
![gitinit.PNG](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481199537/vRqggjVFF.PNG align="left")

# Add url:
 Copy the repository URL from the address bar of your browser
![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481416855/KjaLVMlGO.png align="left")

# Add remote origin:
```
git remote add origin <repo_url>
```
Replace <repo_url> with the URL you copied in the previous step.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481625816/7J3fSbFZ4.png align="left")
Note the ```.git``` we added at the end of the URL

Check to make sure the URL has been successfully added. Use the command below:
```
git config --get remote.origin.url
```
Your output should be similar to:

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481843539/S7_p6wv7d.png align="left")

# Create a file. 
Create a simple text file in the ```first commit``` folder we created in the previous step.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655481947390/c10SuS14X.png align="left")

# Committing the file. 
Switch to your terminal and check for changes using the command:
```
git status
```

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655482099664/fSwyAhocw.png align="left")

Commit the file.
- Stage the changes (the file created) using:
``` 
git add text.txt
```
To stage all change, use:
```
git add .
```

- Commit the changes using the command
```
git commit -m "my first commit"
```
```-m``` is the message flag and the value is ```my first commit ```

Your output should be similar to:

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655482384509/PC_TIWqHA.png align="left")

# Push the changes.
Upload the changes to your remote repository.
Push the changes using the git command:
```
git push --set-upstream origin master
```
Here, **master** is my the branch am pushing to. You can check the branch you are working on using ```git branch```

Your output should be similar to:

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655482621793/9-8Ckm0frL.png align="left")

Refresh the page on your browser.

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1655482707107/hUv5LkDCL.png align="left")

We have successfully pushed our first commit to Github.

*Tell us what you think in the comment section.*

