Git Basics command with example

Hello Developer,

Today we will learn the basics of Git and GitHub. If you don't know about git and gitHub, please read my previous article.

The Git tool is used for uploading your project in the GitHub repository, you must configure the git tool with your email and username before use. It confirms that the git is installed on your PC. Today I am going to show step by step how can you configure your git tool easily. So, let's get started,

Configure Git tool:

Firstly open the git bash by right clicking the empty window and run the following commands:

1.Set email:  git config --global ""

2. Set username:   git config --global "Your Name"

Create your First GitHub Repository:

Go to and follow the following steps

link: GiHub

Step-1: Click new or plus icon

git and github

Step-2: Click new Repository Button

Step-3: Type your repository name if its already exits then show the following error like.

Step-4: Provide a unique name

Step-5: You can manage your repository to make, public, or private. In my case, I made my repository public. Then Obviously un-mark the checkbox.

Step-6: Copy the following two lines of code

First time after creating a git repository what will you do?

Go to your project directory which project do you want to upload in the newly created GitHub repository.
Then open the git tool by right-clicking the empty window and select Git Bash Here link.

Note that obviously you have installed git tool in your pc.

This will open the git client tool and run the following commands to upload those folders and files.

Initialize the git repository (run the following commands)

git init

Add all folders and files to the git repository

git add .
Note. dot(.) means you add all files and folders

Commit the folders and files with a message

git commit -m"my first commit"
Note. "messages goes here to remember your commit workflow"

Finally, go to the newly created git repository in GitHub and copy the following two lines from your repository.

Run those copied two commands

Done you have succeeded the first time uploading your project to GitHub.

After Uploaded the project it looks like in the GitHub



Most useful git command


How to clone a Git Repository

git clone <clone_url>
Example: git clone

How to Create a Branch

git checkout -b <new_branch_name>

Note. It creates a new branch in your git repository by using your given name.

After creating a new branch it automatically switches your current branch to the new branch.

How to Switches between Branches

git checkout <existing_branch_name>
This command switches the user to the current branch to another branch.

Tracking your working status

git status 
Note. This command gives us the history that i have made changed.

Add edited or newly created file

git add .

How to Commit files and folders

git commit -m"commit_messages"

How to Push local files and folders to GitHub Repository

git push 
Note.It works when you are in your master branch.
But when you work as in another branch then the command will be look like...
git push origin <your_branch_name>

Thnaks for reading! 

Read it too

Post a Comment