In this blog, i will take you on a step-by-step journey to master the art of creating index files using a command-line interface on Git Bash. I will also take you through the process of pushing your codes to GitHub
Prerequisite
Ensure you have installed Git Bash on your OS
Ensure you have created a GitHub account
So lets get started.
First thing we do is to configure your environment, that is to ensure you are logged into your GitHub account.
Open your Git Bash and input these commands, remember always to press ENTER after every command line.
git config --global user.name
git config --global user.email
Now we have to create our Folder/Directory. To do this, input the command mkdir, leave a space and give it a name. mkdir means make a directory. "mkdir basefaculty"
Input the command "cd (change directory)" and press enter to open your directory
Input the command "git init" and press enter
This command creates a new Git repository in the current working directory.
You are good to go.
Now we have to create our file and input our code. we are going to create a new empty Text file named index.html.
Input the command "touch index.html" and press enter.
To input code in the empty file, input the command vi
A blank space will appear, Click on the letter "i" on your keyboard to edit the file. Right-click and click on paste, to input your code. Let us use this code below as test. Copy this code from the comment section of this blog, and paste this in the blank page.
<!DOCTYPE html>
My web page
Hello, world!
This is my first web page.
It contains a
main heading and paragraph .
To continue, press the esc button on your PC, input :wq and press enter to close the index.html file
To view your code, input the command cat
Now we will need a repository to house this folder and file, let's quickly create one by going to our GitHub account. To create our repository, login to your GitHub account.
On the upper-left corner of your account, click on the + sign and select "New repository"
Give your repo a name, ensure its public, and tick the "Add a ReadME file" box
On your repository page, click on "Code", copy the url on the HTTPs section, and go back to your Git Bash
We are done creating our repository, now lets go back to our Git Bash and push.
To add a remote repository named "origin" with a specified link to your Git repository, you can use the "git remote add origin" command followed by the remote name ("origin") and the URL of the remote repository.
git remote add origin
To add the file input "git add index.html" and enter
You can confirm if the file has been added by inputting this command.
git status
you should get this feedback
Input this command to create a new commit in your Git repository with a commit message
git commit -m <'the message'>
You can check the status by inputting the "git status" command
Now input the command 'git push origin master' and press enter. This command pushes the commits from your local "master" branch to the remote repository specified by the remote name "origin". After executing the push command, Git will upload your local commits to the GitHub repository in your master branch as shown in the generated command.
On your repository, on the code section, you would notice the default branch is main. To view your index.html file, click on branch and select the master branch.
From the capture below, you can see that our index file and our commit message reflect here.
Click on the text index to see the code we deployed
There you have it, Hopefully this helps.
Top comments (1)
Copy and paste this link on the blank page
<!DOCTYPE html>
My web page
Hello, world!
This is my first web page.
It contains a
main heading and paragraph .