CLI Command

Git Setup

Initializes a new Git repository in the current directory.

git init

Downloads a project and its history from a remote repository.

git clone <url>

Sets your Git username for all repositories on your system.

git config --global user.name $USERNAME

Sets your Git email for all repositories on your system.

git config --global user.email $EMAIL

Repository Initialization

Shows the working directory status including staged, unstaged, and untracked files.

git status

Downloads a project and its entire history from a remote repository.

git clone <url>

Check Status and Logs

Shows the commit history of the current branch.

Shows a compact log with one line per commit.

Displays details about a specific commit.

Shows unstaged changes in your working directory.

Shows changes between staged files and the last commit.

Add & Commit

Stages a file for the next commit.

Stages all changes in the current directory.

Records staged changes with a message.

Stages and commits changes to tracked files in one step.

Branching

Lists all local branches.

Creates a new branch.

Switches to another branch.

Creates and switches to a new branch.

Merges the specified branch into the current branch.

Deletes a branch (if fully merged).

Force-deletes a branch.

Remote Repositories

Shows the remote URLs of the repository.

Adds a new remote named 'origin'.

Pushes the current branch to the remote and sets tracking.

Uploads local commits to the remote repository.

Fetches and integrates changes from the remote branch.

Downloads objects and refs from another repository.

Reset, Revert, Rebase

Moves HEAD back one commit, keeps changes staged.

Moves HEAD back one commit, unstages changes.

Resets HEAD and discards all changes.

Reverts a commit by creating a new inverse commit.

Re-applies commits from the current branch on top of another.

Stashing Changes

Saves uncommitted changes for later.

Lists all stashed changes.

Applies the most recent stash without removing it.

Applies the most recent stash and removes it.

Deletes the most recent stash.

Tags

Lists all tags.

Creates a new tag.

Creates an annotated tag with a message.

Pushes a tag to the remote repository.

Pushes all local tags to the remote.

Inspection

Shows who made each change in a file.

Summarizes commits by author.

Shows a graph of the commit history.

Clean Up

Removes untracked files and directories.

Optimizes the repository by cleaning up unnecessary files.

Shows a log of all HEAD changes (even deleted branches).

Cherry Picking

Applies a specific commit on the current branch.

Submodules

Adds a submodule at a specific path.

Initializes and updates submodules.

Pulls updates in all submodules.

Last updated