LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

git-clear

Reset and clean working directory

TLDR

Clear working directory
$ git clear
copy
Clear with force
$ git clear -f
copy

SYNOPSIS

git clear [options]

DESCRIPTION

git clear is a git-extras command that combines git clean -d -f -x and git reset --hard into a single convenience command. It removes all uncommitted changes, tracked and untracked, including files matched by .gitignore, returning the repository to a pristine state matching HEAD.This is the most aggressive of the git-extras clearing commands: git reset --hard alone only touches tracked files, and git-clear-soft spares ignored files, but git clear wipes everything not committed. By default it asks "Sure? - This command may delete files that cannot be recovered, including those in .gitignore [y/N]:" before proceeding.The operation is destructive and cannot be undone, as it permanently deletes uncommitted work. The -f flag bypasses the confirmation prompt, allowing automated scripts to clean repositories without user interaction. Use with caution in repositories containing valuable uncommitted work or ignored build artifacts you meant to keep.

PARAMETERS

-f, --force

Force without confirmation.

INSTALL

sudo apt install git
copy
sudo dnf install git
copy
sudo pacman -S git
copy
sudo apk add git
copy
sudo zypper install git
copy
brew install git
copy
nix profile install nixpkgs#git
copy

CAVEATS

Irreversibly deletes untracked and ignored files alongside the hard reset; there is no undo. Requires git-extras to be installed.

SEE ALSO

RESOURCES

Copied to clipboard
Kai