# Beginner guide to Git and GitHub

[Git](https://git-scm.com/) is a distributed version control system. Using Git, many developers can make changes to the same code base at the same time without running into accidents like overriding someone else’s changes. Git will only update the differences made to a file.

Let's do a small demo to track and upload a simple markdown file to Github. 

## Git/Github Demo

- First, go to your repositories and click new.

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

- Fill in the repository name and description and click `Create repository`.

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

- Go to your git bash terminal (and make sure that your git is already installed and configured, if not you can find links at the end of this blog.)

- Traverse to the folder/directory where your file resides.

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

- Now to track files on this directory, you need to initialize git onto your folder, use the below command to do that.

```bash
git init
``` 
- You can also check the status of the files using.

```bash
git status
``` 

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

- To start tracking a file (send to staging area) we use.

```
git add .
``` 

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

- To save a version of that file we commit it with a message appropriate.

```
git commit -m "init commit"
``` 

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

- Here we have the file tracked by git in our local system, but if we want our changes to reflect onto the cloud (Github in this case), we first get the URL where we want to store our code, which you will get from your new repo and we can set the branch of the repo.

```bash
git remote add origin git@github.com:prateek-budhiraja/resume.md.git
git branch -M main
``` 
- Everything is set now, we can just push our code to GitHub with

```
git push -u origin main
``` 

![image.png](https://cdn.hashnode.com/res/hashnode/image/upload/v1658602424062/Dv-QSa-ho.png align="left")

- Now when you refresh your repo, you will see your uploaded file.

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

---

## Setup Github pages

You can go to the settings and then to `Pages` and do the below changes.

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

A couple of minutes after you save the settings, you will be able to access your Github pages website on the URL.

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


### Resources 👇
[Setup git with github](https://medium.com/devops-with-valentine/2021-how-to-set-up-your-ssh-key-for-github-on-windows-10-afe6e729a3c0)

