How to Create and Push Files to GitHub with Git Bash: A Beginner's Tutorial

I have a solid background in cloud computing ideas and a strong desire to use cloud technology to address practical issues. I am an enthusiastic and driven cloud developer. Equipped with practical AWS and Azure knowledge, I'm excited to advance in the cloud development industry and add value to dynamic teams.
I am chronicling my daily experiences in the realm of cloud computing on this blog.
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.htmlfile:touch index.htmlCreate the
style.cssfile:touch style.css

To open both files with the vi editor and add some code, follow these steps:
Open
index.htmlwith vi:vi index.htmlAdd 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>Save and exit vi by pressing
Esc, then typing:wqand pressingEnter.Open
style.csswith vi:vi style.cssAdd 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:wqand pressingEnter.

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>


Commit the changes with a message: git commit -m 'input message here'.
Use the git log --oneline command to display a list of commits, showing details, etc.

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 masterThis command will fetch and merge any changes from the remote repository to your local repository, ensuring that your local copy is up to date.
Finally, run the following code:
git push origin masterThis will push the committed changes from your local repository to the remote GitHub repository.




