Git Commands (2)

Git Commands (2)

1. git remote: This command is used to manage the remote repositories for a Git repository. For example, you can use the following command to add a new remote repository called origin:

 $ git remote add origin https://github.com/user/my-project.g

2. git fetch: This command is used to download the objects and references from a remote repository to the local repository. For example, you can use the following command to fetch the objects and references from the origin remote repository:

 $ git fetch origin

3. git gc: This command is used to clean up unnecessary files and optimize the Git repository. For example, you can use the following command to run the garbage collector:

 $ git gc

4. git blame: This command is used to view the commit history for each line of a file in a Git repository. For example, you can use the following command to view the commit history for the file1.txt file:

 $ git blame file1.txt

$ git config --global user.name "RkRavikr12"

$ git config --global user.email "RkRavikr12@example.com"


5. git rev-parse: This command is used to parse revision names and extract information from the revision names. For example, you can use the following command to get the abbreviated commit hash for the HEAD commit:

 $ git rev-parse --short HEAD

6. git show: This command is used to show the details of a specific commit in a Git repository. For example, you can use the following command to show the details of the HEAD commit:

    $ git show HEAD

7. git clean: This command is used to remove untracked files from a Git repository. For example, you can use the following command to remove all untracked files from the repository:

   $ git clean -df

8. git grep: This command is used to search for a specific pattern in the files in a Git repository. For example, you can use the following command to search for the foo pattern in the file1.txt file:

 $ git grep foo file1.txt

9. git submodule: This command is used to manage submodules in a Git repository. For example, you can use the following command to add a submodule called my-module from

the URL:

10. git bisect: This command is used to perform a binary search through the commit history of a Git repository to find a specific commit. For example, you can use the following command to start a bisect search for the buggy commit:

$ git bisect start

$ git bisect bad

$ git bisect good buggy


11. git fsck: This command is used to verify the integrity of the objects in a Git repository. For example, you can use the following command to verify all the objects in the repository:

   $ git fsck --full

12. git cherry-pick: This command is used to apply the changes from a specific commit to the current branch in a Git repository. For example, you can use the following command to apply the changes from the f46f5e5 commit to the current branch:

 $ git cherry-pick f46f5e5

13. git rebase: This command is used to reapply the commits from a branch on top of another branch in a Git repository. For example, you can use the following command to rebase the my-branch branch onto the master branch:

   $ git rebase master my-branch

14. git mv: This command is used to move or rename a file in a Git repository. For example, you can use the following command to rename the file1.txt file to file2.txt:

$ git submodule add https://github.com/user/my-module.git my-mo

 $ git mv file1.txt file2.txt

15. git ls-files: This command is used to list the files in the index and the working tree of a Git repository. For example, you can use the following command to list all the files in the repository:

 $ git ls-files

To view or add a comment, sign in

More articles by Ravi Srivastava

  • Monitoring & Observability

    💡 Introduction to Observability Observability is the ability to understand the internal state of a system by analyzing…

  • 🚀 Deploying an Application on GCP Cloud Run: A Step-by-Step Guide

    🚀 Just Published! 🚀 I recently deployed an application on GCP Cloud Run, and I’ve documented the entire process in my…

  • Deploying an AWS Virtual Machine with Terraform: A Step-by-Step Guide

    Introduction Terraform is an open-source infrastructure as code (IaC) tool that allows you to define and provision data…

  • Mastering Docker: Concepts, Architecture, and Installation Guide

    What is Docker? Docker is a containerization platform that provides easy way to containerize your applications, which…

  • Introduction to Containers

    A container is a standard unit of software that packages up code and all its dependencies so the application runs…

  • Kubernetes Cluster Architecture

    Our Kubernetes cluster is structured into two main sections: Master Node (Control Plane) 🖥️ API Server 🛠️ Scheduler…

    1 Comment
  • Summary Zero to Hero Batch-6, Day-4!

    🚀 Hello Connections, TWS-Community, and Techies! Excited to share insights from Zero to Hero Batch-6, Day-4. Today's…

  • 90DaysOfDevops

    Day-3 Task To view what's written in a file. There are 3 ways to view what's written in a file.

  • Day-2 Task: Basic Linux Commands

    Check your present working directory. Command: pwd 2.

  • Introduction-Day1

    What is DevOps? Its not a method or technology, its a Culture in which you need set of practices, principles that aim…

Others also viewed

Explore content categories