Most uses Git command that every Developers and Programmers should know

Jewel Chowdhury
4 min readJul 23, 2020
Git commands

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

To learn more about visit codesnipeet, so let’s start..

Configure Git

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

2. 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 email and username. 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-1

Step-2: Click new Repository Button

step-2

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

step-3

Step-4: Provide a unique name

step-3

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

Step-6: Copy the following codes

step-5

Then go to the project folder and open the git tool by right-clicking the empty window and select Git Bash Here link.

step-6

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

Then, Initialize the git repository

git init

step-7

Add all folders and files to the git repository

git add .

step-8

Commit the folders and files with a message

git commit -m”my first commit”

step-9

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

step-10

Run those copied two commands

step-11
step-12

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

After Uploaded the project it looks like in the Github

final output

Most useful git command

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

Happy Learning!!!

https://www.codesnipeet.com/2020/07/most-uses-git-command-that-every.html

--

--