← 返回命令列表

Linux command

git-clear 命令

文本

复制后可按需替换文件名、目录或参数。

常用示例

Clear working directory

git clear

Clear with force

git clear -f

说明

git clear is a git-extras command that combines git reset --hard and git clean operations into a single convenience command. It removes all uncommitted changes, both tracked and untracked, returning the repository to a pristine state matching HEAD. This command is useful when you want to completely abandon all local modifications and start fresh. It's more aggressive than git reset --hard alone, which only removes changes to tracked files, leaving untracked files intact. The operation is destructive and cannot be undone, as it permanently deletes uncommitted work. The -f flag bypasses confirmation prompts, allowing automated scripts to clean repositories without user interaction. Use with caution in repositories containing valuable uncommitted work.

参数

-f, --force
Force without confirmation.

FAQ

What is the git-clear command used for?

git clear is a git-extras command that combines git reset --hard and git clean operations into a single convenience command. It removes all uncommitted changes, both tracked and untracked, returning the repository to a pristine state matching HEAD. This command is useful when you want to completely abandon all local modifications and start fresh. It's more aggressive than git reset --hard alone, which only removes changes to tracked files, leaving untracked files intact. The operation is destructive and cannot be undone, as it permanently deletes uncommitted work. The -f flag bypasses confirmation prompts, allowing automated scripts to clean repositories without user interaction. Use with caution in repositories containing valuable uncommitted work.

How do I run a basic git-clear example?

Run `git clear` in a terminal, then adjust file names, paths, flags, or remote targets for your system.

What does -f, --force do in git-clear?

Force without confirmation.