Pushing Index files to GitHub using Git Bash
Published: 2023-07-01 13:24:59

In this article , you will learn how to create a simple website and push to GitHub using a GitBash. As a developer, GitBash is a terminal , a place where you can keep your codes and use later for future deployment.
**REQUIREMENTS**

1. Download Git Bash on your local machine.
2. Sign up to a GitHub account
**Procedures**

On your local machine ,open your git Bash and wait for the shell prompt to display,
To Begin ,type the following commands:
`git config --global user.name "your username"
git config --global user.email "your email"
`
![gitconfiglocal01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/wnse7l481pjpsbrge1m3.png)"
**CREATE A DIRECTORY AND INITIALIZE IT.**

1. To make a new directory use this command: `mkdir "directory name"`
2. To open the new created directory `cd "directory name"
git init`

![gitblog01](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/m2utfiu2f7rsiczbeg6h.png)
3. Create a file index.html using command touch index.html
4. To add content in the new file type vi index.html, In 
   the new window, press i on you keyboard to edit and add 
   content.

![gitblog2](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ss1zw5m6qpb32s7c5y2.png)

![gitblog03](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7ziwuex88ydrfiaca10y.png)
5. When done ,press esc key and :wq , to save and exit.

**CREATING A REPOSITORY**
1. Login to your GitHub account ,on the dashboard ,by the + 
   icon with a dropdown arrow and select create new 
   repository.

![gitblog04](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/67hbhxd66w6kupnbfjtg.png)
2. In the new window opened, enter a name for your 
   repository, and enter ensure to checkbox the "Add Readme 
   file".

![gitblog06](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6k7zti9zxk5grzkwh4xk.png)
3. Click the create Repository button 

![gitblog07](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/27qsss8b45f5f8xt5cjk.png)
4. On the window that opens, click on the Code button, 
   Under HTTPS copy the address. 
![gitblog08](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xa8ifwv56e6honn6xr5x.png)
**CLONING YOUR REPOSITORY**
On your Git bash window, type the command :` git remote add origin "Paste the URL of the GITHUB here"` and press Enter key.
![gitblog09](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x5q5rnshf5p4amtzfgwn.png)
**STAGING AND COMMITING THE FILE**
1. To stage your files type the command: `git add "name of 
   your file"`
2. To commit type the command:` git commit -m "A message of 
   your choice" `. The commit message is anything of your 
   choice.

![gitblog10](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/q6r9f0vc7vca3ff33oug.png)
**PUSHING YOUR FILES TO GITHUB**
To push files from your local machine to GitHub, we use the command: `git push origin master` 
If you are doing it for the first time authentication may be required from you.

![gitblog11](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnvunkowefrnxhgc5ob1.png)
From the above diagram, we can see that our index.html file has been pushed successfully to GitHub.
**VIEWING CONTENT ON GITHUB**
On GitHub dashboard, at your left-hand side, under Top Repositories, select the repository you created in this lesson. When the window opens, click the button _"Compare and pull Request"_

![gitblog12](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2zjll25vjurehye94d3h.png)Click on the Master ,the file Index.html

![gitblog13](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/p03p7ht7koiamegn7c4x.png)
In conclusion, we have successfully pushed our remote file ,index.html to GitHub. GitHub , bitbucket are trusted developer sites where our codes can be stored.