Command: git undo - arxanas/git-branchless Wiki


git undo is an undo command which can undo any operation to the commit graph, such as the following:

git undo offers a convenient visual interface to browse previous states of the repository and go back in time. See the demo below:

Operations other than those to the commit graph, such as operations which affect the working copy, can't be undone with git undo. See What can't git undo do?, and check the Undo reference table for another solution to your problem. You can also start a new discussion to ask questions.


git undo is an interactive program which shows you the previous states of the repository. See the demo for an example.

Use the arrow keys to move forward or backward in time, and find the version of the commit graph you want. Then press enter, and it will show you a list of operations to carry out, which you can either accept or reject:

$ git undo previous state interactively...
Will apply these actions:
1. Hide commit 8d4738cd new message

Confirm? [yN] y
Applied 1 inverse event.

What can't git undo do?

git undo is only responsible for editing the commit graph. It doesn't undo changes to the working copy. Here's some examples of things which it doesn't (currently) do:

See the reference table below.

Undo reference table

Here are some topics from, and whether they can be accomplished with git-branchless. The goal is to make most of these effortless with future work.

Problem Solution Planned for git-branchless? Proposed command
#1 Discarding All Local Changes in a File git restore Yes git stage
#2 Restoring a Deleted File git restore Yes git undo (see design)
#3 Discarding Chunks / Lines in a File git add -p Yes git stage
#4 Discarding All Local Changes git restore No
#5 Fixing the Last Commit git commit --amend Yes git amend
#6 Reverting a Commit in the Middle git rebase -i Yes git adjust
#7 Resetting to an Old Revision git undo
#8 Resetting a File to an Old Revision git restore No
#9 Recovering Deleted Commits git undo
#10 Recovering a Deleted Branch git undo
#11 Moving a Commit to a New Branch git move
#12 Moving a Commit to a Different Branch git move
#13 Editing Old Commit Messages git rebase -i Yes git reword
#14 Deleting Old Commits git rebase -i Yes git adjust
#15 Squashing Multiple Commits Into One git rebase -i Yes git adjust
#16 Adding a Change to an Old Commit git commit --amend Yes git amend/git adjust/git absorb
#17 Splitting / Editing an Old Commit git rebase -i Yes git split