Basic Git commands

Get started with Git commands

Git is a source control management system. Git is a widely used tool for code management recently. Git is one of the most mandatory tools to learn for any Developer or Software Engineer. It is used widely in the IT professional world.

Today, Let’s understand some basic git commands

1. Git Clone

  • Clone a repository from Remote Origin to the local system
  • There are 2 ways to clone any repository
    1. SSH

To clone using SSH Keys, you must configure SSH Keys in your system from your respective Git provider (Github, GitLab, bitbucket, etc.)

After adding SSH keys, clone using below command

git clone

To clone using HTTP/HTTPS method, you will require Username and password

For HTTPS, Clone using below command

git clone

Both of above commands, will clone code in current working directory

To clone it in custom directory, add PATH of that directory at the end

for e.g.

git clone gitcode/democode

2. Git fetch

to fetch recent changes in branches and tags to our local repository

  • fetch all remote branches
git fetch --all
  • At time of fetching, remove any remote references that no longer exist on the remote
Git fetch --prune

3. Git branch

to list current working branch

git branch

to list all remote available branch

git branch -a

to delete branch from local source control

git branch -D $BRANCH_NAME

4. Git checkout

to checkout any remote branch or tag

git checkout $BRANCH_NAME 
git checkout $TAG_NAME

to create new branch and checkout

git checkout -b $BRANCH_NAME

5. Git pull

to get all changes from remote to local environment

git pull origin $BRANCH_NAME


  1. You can pull changes of same remote branch to local branch
  2. In case, you wish to merge your current branch in some other branch and to avoid merge conflicts
    1. Take pull from MR Source branch
    2. Take pull from MR Target branch
    3. Generate MR

6. Git add

add files to track using git

git add filename 

to add all files to track

git add . 

7. Git commit

You need to commit your code to save it in git source control

To commit your code

it will open your default text editor to write commit message

git commit 

To commit code and to write commit message in one line, use below command

git commit -m "commit messages"

While writing git commit message, it is recommended to use certain format, so other users can understand commit changes easily

Basic git conventional messages are available here

8. Git push

to push your local changes to remote

to push your committed code changes in remote branch, use below command

git push origin $BRANCH_NAME

9. Git stash

Stash changes you did to current branch, in case they are no longer needed, or if you need to work on some other tasks.

git stash

10. Git rebase

to rebase our current branch with other branch’s changes.
It can be alternative approach to git pull from other branch

git rebase $OTHER_BRANCH_NAME (e.g. development)

11. Git status

  • to see current branch name
  • to see un-committed changes
  • to see tracked and un-tracked files in current branch
git status

Visit our website for more such information

Also read this article

Drafted On,
November 25, 2020
DevOps @

2 thoughts on “Get started with Git commands”

  1. Hello Identical cloud,

    As per your webinar with Vishwakarma college, I have followed your blog and YouTube videos but I’m really sorry it’s not reliable. your content is amazing but not regularly updated and you don’t have cover all the topics.

    Thank you.

    • Hello Rajeshwari,

      Thank you for your feedback. We appreciate your concern and will try to provide more detailed videos and blogs frequently.

      IdenticalCloud Team


Leave a Comment