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?
Asked
Active
Viewed 505 times
0
-
1I 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 Answers
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
-
-
Nice! Now I only need to set it as a default for git, I will probably use that more often.. Thanks! – Tim Baas Jul 02 '13 at 13:02
-
1you can also use git-extras (cf http://stackoverflow.com/a/8487487/1290438) that provides a nice `git undo` alias. – zmo Jul 02 '13 at 13:03
-