Pushing to GitHub the right way

Pushing to GitHub the right way

Pushing to GitHub?

You may say “this is probably the easiest thing to do” but believe me a lot of people do not find it as easy as you do.

git push is no doubt one of the most important and commonly used git command.

git push is used to push or (in layman terms) send already committed files to a remote repository.

I will be showing you how to make a simple and successful push to GitHub.

First we have to setup our working environment.

Download and install Git on your local machine. Click here to learn how to download and install Git on your local machine.

Login to your GitHub account or create a new account if you do not have one. Click here to create a new GitHub account.

If you have successfully completed the steps above. Good Job 👍 You are doing well!!!

Now create a new GitHub repository by clicking on the new icon.

Type in the name of the repository you want to create (for this tutorial let us name our new repository lucidTest) and click Create Repository.

You’ll be directed to a page like this

Copy the https link

Copy the https link

Now open GitBash on your local machine and navigate to the directory you want to clone to.

To clone the repository use the git clone command followed by the link you copied earlier then click enter.

Congratulations!!! 🎉 you have successfully cloned your remote repository to your local machine.

Now we have to create a file in the lucidTest folder, and push it back to our remote repository.

To do that we have to open our lucidTest folder in any preferred text editor, I will use my preferred text editor which is VSCode. After opening the folder, create a file e.g test.txt and save it. Make sure the file is saved.

Now go back to GitBash and add the file to the staging state using the git add command followed by the name of the file (test.txt) we created.

If you did that correctly your file is ready for commit.

To commit your file use the git commit -m command followed by your commit message.

One more thing!

Pushing to GitHub

Use the git push -u origin master command to push to GitHub.

A prompt will appear asking for your GitHub username and password don’t panic put in your username and password and your file will be pushed to your remote repository on GitHub

Go to the lucidTest repository on GitHub and confirm your push was successful.

If your push was successful congratulations!!! 💐 you just made a push to GitHub the right way.