Undo is a command in many computer programs. It erases the last change done to the document reverting it to an older state. In some more advanced programs such as graphic processing, undo will negate the last command done to the file being edited.
Questions tagged [undo]
829 questions
24809
votes
100 answers
How do I undo the most recent local commits in Git?
I accidentally committed the wrong files to Git, but didn't push the commit to the server yet. How do I undo those commits from the local repository?

Hamza Yerlikaya
- 48,537
- 42
- 142
- 238
10682
votes
38 answers
How do I undo 'git add' before commit?
I mistakenly added files to Git using the command:
git add myfile.txt
I have not yet run git commit. How do I undo this so that these changes will not be included in the commit?

paxos1977
- 147,191
- 27
- 92
- 126
5146
votes
24 answers
Reset local repository branch to be just like remote repository HEAD
How do I reset my local branch to be just like the branch on the remote repository?
I tried:
git reset --hard HEAD
But git status claims I have modified files:
On branch master
Changes to be committed:
(use "git reset HEAD ..." to unstage)
…

hap497
- 145,385
- 43
- 80
- 95
4657
votes
35 answers
Undo a Git merge that hasn't been pushed yet
I accidentally ran git merge some_other_branch on my local master branch. I haven't pushed the changes to origin master. How do I undo the merge?
After merging, git status says:
# On branch master
# Your branch is ahead of 'origin/master' by 5…

Matt Huggins
- 79,192
- 36
- 147
- 216
3944
votes
19 answers
Undoing a git rebase
How do I easily undo a git rebase? A lengthy manual method is:
checkout the commit parent to both of the branches
create and checkout a temporary branch
cherry-pick all commits by hand
reset the faulty rebased branch to point to the temporary…

webmat
- 55,636
- 12
- 54
- 59
1929
votes
15 answers
Undo working copy modifications of one file in Git?
After the last commit, I modified a bunch of files in my working copy, but I want to undo the changes to one of those files, as in reset it to the same state as the most recent commit.
However, I only want to undo the working copy changes of just…

hasen
- 157,263
- 64
- 188
- 228
1730
votes
12 answers
How to undo "git commit --amend" done instead of "git commit"
I accidentally amended my previous commit. The commit should have been separate to keep history of the changes I made to a particular file.
Is there a way to undo that last commit? If I do something like git reset --hard HEAD^, the first commit also…

Jesper Rønn-Jensen
- 101,109
- 43
- 115
- 152
1718
votes
12 answers
Can I delete a git commit but keep the changes?
In one of my development branches, I made some changes to my codebase. Before I was able to complete the features I was working on, I had to switch my current branch to master to demo some features. But just using a "git checkout master" preserved…

tanookiben
- 20,305
- 7
- 26
- 25
1255
votes
8 answers
How to uncommit my last commit in Git
How can I uncommit my last commit in git?
Is it
git reset --hard HEAD
or
git reset --hard HEAD^
?

richard
- 12,891
- 3
- 17
- 9
1151
votes
17 answers
git undo all uncommitted or unsaved changes
I'm trying to undo all changes since my last commit. I tried git reset --hard and git reset --hard HEAD after viewing this post. I responds with head is now at 18c3773... but when I look at my local source all the files are still there. What am I…

Antarr Byrd
- 23,455
- 30
- 93
- 175
739
votes
13 answers
How do I "un-revert" a reverted Git commit?
Given a change that has been committed using commit, and then reverted using revert, what is the best way to then undo that revert?
Ideally, this should be done with a new commit, so as to not re-write history.

JimmidyJoo
- 9,685
- 7
- 25
- 30
721
votes
10 answers
How do I do redo (i.e. "undo undo") in Vim?
In Vim, I did too much undo. How do I undo this (that is, redo)?

flybywire
- 250,866
- 188
- 393
- 498
304
votes
8 answers
How to undo a git pull?
I would like to undo my git pull on account of unwanted commits on the remote origin, but I don't know to which revision I have to reset back to.
How can I just go back to the state before I did the git pull on the remote origin?

Kartins
- 3,359
- 3
- 16
- 17
193
votes
6 answers
Git undo changes in some files
While coding I added print statements into some files to keep track of what was going on.
When I am done, is it possible to revert changes in some files, but commit the file I actually worked on?
Say I added print in file A, but I modified file B.…

Hamza Yerlikaya
- 48,537
- 42
- 142
- 238
187
votes
8 answers
Undo git update-index --skip-worktree
A while ago I did this to ignore changes to a file tracked by git:
git update-index --skip-worktree
Now I actually want to commit changes to that file to source. How do I undo the effects of skip-worktree?

Kevin Burke
- 57,082
- 72
- 182
- 294