In this tutorial you will learn about the use of some common git commands. this commands will help you in your daily works for programming of the projects. Git is widely used in the IT industry.

what is Git ?

it’s an Open Source Distributed Version Control System. It helps in tracking changes in source code, enabling different people to collaborate on different parts of the same project

working with local repository

Command: Git config

The git config command is used initially to configure the user.name and user.email.The Git config command is the first and necessary command used on the Git command line.

Syntax:

$ git config --global user.name "yourname"  
$ git config --global user.email "youremail@gmail.com" 

Example:


Command: Git init

Create an empty Git repository or reinitialize an existing one. A .git folder is created in your directory. This folder contains Git records and configuration files.

Syntax:

$ git init Demo

Example:


Command: Git add

This command is used to add one or more files in the staging area. you can also use . for add changed files at a time.

Syntax:

$ git add filename
$ git add .

Example:


Command: Git commit

This command is used to finalize your change and make it ready to push to the server. Remember that anything that is still upstaged — any files you have created or modified that you haven’t run git add on since you edited them — won’t go into this commit. They will stay as modified files on your disk. In this case, let’s say that the last time you ran git status, you saw that everything was staged, so you’re ready to commit your changes.

Syntax:

$ git commit -m "message about changes made"

Example:


Command: Git Status

This command is used to display the status of your working directory.

Syntax:

$ git status

Example:


Command: Git branch

git branch command is used to view list all the branches available in the repository. if you want the list of branch from remote just add -r after this command and will return all branch available on remote.

Syntax:

$ git branch

Example:


Command: Git checkout

The git checkout command is used to switch branches if you work in another branch this command is used.

Syntax:

$ git checkout branch_name 

Example:


Command: Git merge

The git merge command is used to merge one branch to another branch.

Syntax:

$ git merge branch_name

working with remote repository

Command: Git remote

Git remote command is used to connect your local repository to remote server. This command doesn’t provide real-time access to repositories.

Syntax:

$ git remote add origin <address>

Example:


Command: Git clone

This command is used to make a copy of a repository from an existing.

Syntax:

$ git clone URL

Example:


Command: Git pull

Pull command is used to receive data from the current active branch. It fetches and merges changes on the remote server to your working directory.

Syntax:

$ git pull URL

Example:


Command: Git push

The command git push is used to transfer the commits or pushing the content from the local repository to the remote repository.

Syntax:

$ git push -u origin master

Example:


So that’s it here is commonly used commands you have and we will add more commands that are used for git version controls for you
Or if you need any kind of support or help contact us by sending form contact form and our developer will connect with you to solve the problem

Leave a Reply

Your email address will not be published. Required fields are marked *