Skip to main content

Command Palette

Search for a command to run...

Basic Git Command Everyone Should Know

Updated
•2 min read•View as Markdown
Basic Git Command Everyone Should Know

Lets first understand what is Git and its benefits, then we dive into its command.

Git is know as Versioning Control which plays a very important role while development of any project. We can track what, when, who, where changes are made.

Benefits

  • It’s free (and open-source)
  • It is faster and more reliable than any other version control software
  • Security is high
  • Widely used in many organization

Git Commands

1. git help

Using git –help in the command prompt will give you a list of available commands

$ git -help

2. git init

The git init command is used to initialize a new git repository or reinitialize an existing one

$ git init

3. git clone

This command is used for downloading the latest version of a remote project and copying it to the selected location on the local machine. It looks like this:

$ git clone <repository url>

4. git status

This command is used to show new file or changes which are not committed yet

$ git status

5. git pull

This command will fetch all the changes from the remote repository and merge any remote changes in the current local branch.

$ git pull

6. git commit

Git commit is used to committing your local branch changes.

$ git commit -m <"commit message">

7. git push

Git push will push the locally committed changes to the remote branch.

$ git push

8. git add

Git add is use to stage changed files. You can stage individual files:

$ git add <file path>

Or all files:

$ git add .

9. git log

This command is used to check the commit history of a repository

$ git log

9. git checkout

This command is used to switch on any other branch

$ git checkout

Or if you want to create a new branch and switch to it, then use

$ git checkout -b <branch name>

These are some basic commands which we mostly used. Hope those will help you.

32 views