How to Create an Index file in Gitbash and Push it to Gitgub
Published: 2023-07-02 18:00:38

In this blog I will be using Gitbash, a command line interface to create an in-index html file and push it to the githup repository.

**Configure your environment** 
a. Enter this command: **_git config –global user.name <your username>_**, press enter.
b. Enter also: **_git config –global user.email <your email>_**, press enter.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9hb2wyoqisripc46jt1a.png)

**Make directory/ Create a folder**
c. Make and change into the directory by Input the command below: 
**_mkdir joseweb_** and **_cd joeweb_**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hp7a85wjanwx180oya4p.png)
d. Initialize your new git repo in the working directory you created above using the this command: **_git init_**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/w2pfhbgotldfxw285aps.png)
e. Create an html file (index.html) by inputing this command:
**_Touch index.html_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/oovnri1wff5s6izlj6ie.png)

f. Input code into the html file using this command: _**vi <file name>**_
A blank space will be opened, right click and paste your html code into the git blank space, continue by pressing escape key., and: **_wq_** to save and close the index.html file.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/j9u0phzsvpifauyr0qx1.png)
h. View you code by typing this command: **_cat <file name>._**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/lch0fy28ewmj6htowpwm.png)


**_Create the Repository in github_**
You will need to create a repo to house your file using you github account
a.	On the githuB page click on create new repo.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/b7utx5a20g1jik705xep.png)
b. Enter the repository name, give theit a description, select public, initialize by checking add a README file, then click on create repository.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9r3uakmpdidlcp7rb3e8.png)
c. On the repo page, click on Code and copy link under HTTPS.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/57iz1q5z55ank6fijfao.png)
d. After successfully creating the repository, copy the HTTPs URL into the Gitbash.

**Push to Github**
a. To add the repo created in the githug into the gitbas we use the command: **_git remote add origin_**, followed by the remote name (**_origin_**) and the URL:
**_Git remote add origin <remote repo url>_**

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tovuzze1iubls2jrta6h.png)

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hzogjvuun8n45iz5s53o.png)
b. Add the index file and press enter with this command: **_Git add index.html_**. type git status to check if the html file has been added.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xnpm3fi8l1c2k4o2dd4h.png)
c. Create a new commit in your git repo with a commit message using this command **_git commit -m <message>_**. Check again by using **_git status_**.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3wz6wantb6t9tw1jxp9i.png)
d. You can then use this command **_git push origin master_** to push the commit from the local _**master**_ branch (i.e. index file from your loacal system) to the remote repo (githup repo) being specified by the name **_origin_**.
 
![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9ael6zs71lidxq1dxnc1.png)

On the execution of the command above, your loacal commit (index file) will be uploaded to the github repo in your master as shown in the generated result above.
e. On your githb repo, “you will see master had recently been pushed” i.e. the commit you just push, see main as default branch. Select master and you will be able to view the index.html you pushed.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/izni53qqk143t41ecx6u.png)

**NOTE:** The capture above shows the index.html file and the commit message inputted from gitbash, this shows file was successfully pushed to repo.
f. Open the index.html to verify the content.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k6ws0jxgxrpl5j39v1j6.png)

**Conclusion**:-The blog shows that the web contents (html code) has successfully been pushed from gitbash command line interface to the github repository.