# Commands

## Overview

Git commands are instructions use to interact with Git, a version control system. Version control systems track changes made to files over time, allowing to revert to previous states, collaborate with others, and see the history of your project.

Git commands can be broadly categorized into -

## **Setup and Configuration Commands**

`git config`: Used to configure Git settings, such as user name and email, editor, and alias.

## **Getting and Creating Projects**

`git init`: Initializes a new Git repository.

`git clone`: Creates a copy of an existing Git repository from a remote server.

## **Basic Snapshotting**

`git add`: Adds files to the staging area.

`git commit`: Records changes to the repository.

`git status`: Shows the working tree status.

`git diff`: Shows changes between commits, commit and working tree, etc.

## **Branching and Merging**

`git branch`: Lists, creates, or deletes branches.

`git checkout`: Switches branches or restores working tree files.

`git merge`: Merges branches.

`git rebase`: Reapplies commits on top of another base tip.

## **Sharing and Updating Projects**

`git fetch`: Downloads objects and refs from another repository.

`git pull`: Fetches from and integrates with another repository or a local branch.

`git push`: Updates remote refs along with associated objects.

## **Inspection and Comparison**

`git log`: Shows commit logs.

`git show`: Displays various types of objects.

`git diff`: Shows changes between commits, commit and working tree, etc.

`git blame`: Shows what revision and author last modified each line of a file.

## **Debugging**

`git bisect`: Uses binary search to find the commit that introduced a bug.

`git grep`: Searches for patterns in the repository.

`git fsck`: Verifies the connectivity and validity of objects in the database.

## **Patching**

`git apply`: Applies a patch to files and/or the index.

`git am`: Applies a series of patches from a mailbox.

## **Stashing and Cleaning**

`git stash`: Temporarily stores changes that are not ready to be committed.

`git clean`: Removes untracked files from the working directory.

## **Advanced Manipulations**

`git reset`: Resets current HEAD to a specified state.

`git reflog`: Manages reflog information.

`git cherry-pick`: Applies the changes introduced by existing commits.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://www.pranaypourkar.co.in/the-programmers-guide/git/commands.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
