3 ms·
git reset --soft HEAD~1 git status ..remove files that was to be commited.. git commit -m "previous message"
by alrlroipsp 4y ago
git reset --soft HEAD~1
git status
..remove files that was to be commited..
git commit -m "previous message"
- pxmpxm 4y agoUh huh, now imagine you've built something with usage in mind, rather than a hodgepodge of leaky abstractions for what's happening behind the scenes: git undo git undo file
- RHSeeger 4y agoThis right there is the what gives me pause. Every time I need to do something out of the box, I need to start googling. Rather than there being an easy to remember command to do it, one that has a good name that indicates what it does; or, more specifically, what one uses it to accomplish. It's like naming a field "list" in code; I know it's a list... but name it so I know what is in it or what it's for. And to add to the fun, there's multiple other answers in this thread on how to accomplish the same task.
- iam-TJ 4y agogit reset --soft HEAD^ # make changes so index only contains what you want git commit -a -C ORIG_HEAD of if you prefer: git config --global alias.undo reset --soft HEAD^ git config --global alias.redo commit -a -C ORIG_HEAD then: git undo # make changes so index only contains what you want git redo You could use -c (--reedit-message=) instead of -C (--reuse-message=) for further flexibility. ORIG_HEAD is set to point to the most recent HEAD when using reset. See "man git-reset" > EXAMPLES > "Undo a commit and redo".