← 返回命令列表

Linux command

git-undo 命令

文本

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

常用示例

Undo last commit

git undo

Undo N commits

git undo [3]

Undo and keep changes staged

git undo --soft

Undo and discard changes

git undo --hard

说明

git undo removes the last commit(s) while keeping changes in the working directory (unstaged). It is a convenient wrapper around `git reset` that defaults to a mixed reset, preserving all work. Without arguments, it undoes the most recent commit. Pass a number to undo multiple commits. Use --soft to keep changes staged, or --hard to discard them entirely.

参数

--soft
Keep changes staged.
--hard
Discard all changes.
--help
Display help information.

FAQ

What is the git-undo command used for?

git undo removes the last commit(s) while keeping changes in the working directory (unstaged). It is a convenient wrapper around `git reset` that defaults to a mixed reset, preserving all work. Without arguments, it undoes the most recent commit. Pass a number to undo multiple commits. Use --soft to keep changes staged, or --hard to discard them entirely.

How do I run a basic git-undo example?

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

What does --soft do in git-undo?

Keep changes staged.