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.

810 questions
98 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 can I undo those commits from the local repository? The only way seems to be to copy the edits in some kind of GUI text editor, then wipe the whole…
Hamza Yerlikaya
  • 48,189
  • 40
  • 139
  • 234
37 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. Is there a way to undo this, so these files won't be included in the commit?
  • 143,025
  • 26
  • 88
  • 126
22 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 did: git reset --hard HEAD But when I run a git status, On branch master Changes to be committed: (use "git reset HEAD ..." to unstage) modified: …
  • 139,035
  • 43
  • 78
  • 92
33 answers

Undo a Git merge that hasn't been pushed yet

Within my master branch, I did a git merge some-other-branch locally, but never pushed the changes to origin master. I didn't mean to merge, so I'd like to undo it. When doing a git status after my merge, I was getting this message: # On branch…
Matt Huggins
  • 77,174
  • 34
  • 142
  • 216
19 answers

Undoing a git rebase

Does anybody know how to easily undo a git rebase? The only way that comes to mind is to go at it manually: git checkout the commit parent to both of the branches then create a temp branch from there cherry-pick all commits by hand replace the…
  • 53,626
  • 12
  • 53
  • 59
14 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…
  • 153,743
  • 63
  • 185
  • 225
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
  • 97,441
  • 42
  • 114
  • 150
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…
  • 18,565
  • 7
  • 25
  • 25
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^ ?
  • 12,223
  • 3
  • 16
  • 9
15 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
  • 22,408
  • 29
  • 90
  • 163
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)?
  • 244,016
  • 187
  • 391
  • 495
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.
  • 8,905
  • 7
  • 24
  • 30
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,199
  • 3
  • 16
  • 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
  • 48,189
  • 40
  • 139
  • 234
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
  • 54,154
  • 69
  • 174
  • 285
2 3
53 54