Hackernoon logoGit Basics by@codesnipeet

Git Basics

Jewel Chowdhury Hacker Noon profile picture

@codesnipeetJewel Chowdhury

Competitive programmer and web developer. Owner at codesnipeet.com

To playing with git you have to do the following things step by step

First of all, guys, you have to know the term Git and gitHub. Then we will learn all the basic commands and how it works.So read the introduction part,

Then, start with me

Configure Git:


Set email: git config --global user.email "you@example.com"


Set username: git config --global user.name "Your Name"

Create a new Repository

To use the git tool for uploading your project in the GitHub repository, you must configure the git tool with your

. 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.

Step-1: Click new or plus icon

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 repo public. Then Obviously unmark the checkbox.

Step-6: Copy the following codes

Then go to the project folder and 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.

Initialize the git repository

git init

Add all folders and files to the git repository

git add .

Commit the folders and files with a message

git commit -m”my first commit”

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 in the github it looks like

Most useful git commandClone a Git Repository

git clone <clone_url>

Example: git clone https://github.com/jewelcse/login-registeration-in-php.git

Create a Branch

git checkout -b <new_branch_name>

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.

Switches between Branches

git checkout <existing_branch_name>

This command switches the user to the current branch to another branch.

Track your working status

git status

Add edited or newly created file

git add .

Commit files

git commit -m"commit_messages"

Push local files to GitHub

git push

It works when you are in your master branch.

But when you work as in another branch then the command will be

git push origin <your_branch_name>

To learn more about visit: https://www.codesnipeet.com

Happy Learning!!!


Join Hacker Noon

Create your free account to unlock your custom reading experience.