0

I just did add and commit on my repository, did not push it yet. Now there are files in the commit that actually needed to be ignored. So I need to undo that add and commit, but all files need to stay the same. What to do?

Tim Baas
  • 6,035
  • 5
  • 45
  • 72
  • 1
    I have searched, but most questions and also the link just mentioned don't explicitly ask for the repository to stay the way it is. So I was unsure. But now I see the `reset --soft` option is what I need. Too bad it is downvoted this quicly.. – Tim Baas Jul 02 '13 at 12:58
  • the `git reset --soft HEAD^` does not touch the state of the repository, it just removes last commit and put back all committed files in the index like it was just before you've done the `git commit`. Then you just need to remove the file you want to put out of the commit from the index. – zmo Jul 02 '13 at 13:02

1 Answers1

2

just for that kind of problems, I have added in my ~/.gitconfig file the following alias:

[alias]
undo = reset --soft HEAD^
zmo
  • 24,463
  • 4
  • 54
  • 90