How to Create and Push Files to GitHub with Git Bash
To create files in Git Bash and push it to a GitHub repository, start by opening Git Bash.
Let’s start by signing into our local environment using our username and email.
Let’s input the following command:
git config --global user.name
Press Enter, then
git config --global user.email
Then Enter.

Confirm your settings by entering the following command:

Next, create a new Git repository on GitHub. Once the repository is created, clone it to your local machine using the following steps:
- Clone the Repository to Your Local Machine:
- Copy the repository URL from GitHub.
- Open Git Bash and navigate to the directory where you want to clone the repository.
- Run the following command, replacing
<repository-URL>
with the URL you copied:

Navigate into your cloned repository by using the cd
command followed by the repository name.

Create the index.html
and style.css
file:
touch index.html style.css

To open both files with the vi editor and add some code, follow these steps:
- Open
index.html
with vi: Add the following basic HTML structure:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="style.css">
</head>
<body>
<h1>Hello, World!</h1>
<p> My very first simple website</p>
</body>
</html>
Add the following basic CSS:
body {
font-family: Arial, sans-serif;
background-color: #f0f0f0;
margin: 0;
padding: 0;
}
h1 {
color: #333;
text-align: center;
margin-top: 20%;
}
Save and exit vi by pressing Esc
, then typing :wq!
and pressing Enter
.
After adding the code, you can proceed to stage, commit, and push the changes to your GitHub repository.
To add the files for tracking and commit, follow these steps:
- Stage the files for tracking: git add <file-name>


2. Commit the changes with a message: git commit -m ‘input message h ere’. Use the git log –oneline command to display a list of commits, showing details, etc.

3. Push the changes to the GitHub repository:
But before we push to the remote GitHub repository, let’s make sure that the local repository is up to date with the remote by running the following command:
git pull origin master
This command will fetch and merge any changes from the remote repository to your local repository, ensuring that your local copy is up to date.
git push origin master
This will push the committed changes from your local repository to the remote GitHub repository.

Greetings! I am Charly, an aspiring DevOps Engineer. Recently, I began the lengthy process of transitioning from Logistics to Technology. Technology has been my passion, having worked in tech support in the past. Welcome to my blog, where I will chronicle my daily learning journey toward becoming a DevOps Engineer.