Questions tagged [undo]

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.

854 questions
105 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
  • 49,047
  • 44
  • 147
  • 241
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?
  • 153,307
  • 27
  • 93
  • 128
27 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) …
  • 154,439
  • 43
  • 83
  • 99
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
  • 81,398
  • 36
  • 149
  • 218
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…
  • 58,466
  • 12
  • 54
  • 59
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…
  • 161,647
  • 65
  • 194
  • 231
13 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…
  • 22,575
  • 8
  • 27
  • 25
13 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
  • 106,591
  • 44
  • 118
  • 155
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^ ?
  • 13,881
  • 3
  • 18
  • 9
16 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
  • 24,863
  • 33
  • 100
  • 188
14 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.
  • 10,503
  • 7
  • 27
  • 30
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)?
  • 261,858
  • 191
  • 397
  • 503
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?
  • 3,469
  • 3
  • 17
  • 17
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
  • 49,047
  • 44
  • 147
  • 241
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
  • 61,194
  • 76
  • 188
  • 305
2 3
56 57