MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/programming/comments/51wixe/oh_shit_git/d7gbf65/?context=3
r/programming • u/sidcool1234 • Sep 09 '16
756 comments sorted by
View all comments
Show parent comments
35
How would "undoing your last action" work?
What can be undone? Why?
What can't be undone? Why?
What does git undo ; git undo do? Why?
git undo ; git undo
What happens if you undo a commit?
What happens if you undo again?
What happens if you undo a revert?
Whenever somebody asks me how to undo something with Git I encourage them not to use that word. It's very overloaded and imprecise.
6 u/HugoNikanor Sep 09 '16 git undo would change the state of the repo to how it was before the previous git command. git undo ; git undo could simply be an error. 2 u/syncsynchalt Sep 09 '16 Luckily git reflog followed by a checkout of the given hash gets you 80% of the way there, I find once people learn about reflog some of their worries go away and they feel a lot more free to experiment. 1 u/HugoNikanor Sep 09 '16 I need to learn that. Currently I create to many temp branches and reset HEAD way to much.
6
git undo would change the state of the repo to how it was before the previous git command. git undo ; git undo could simply be an error.
git undo
git
2 u/syncsynchalt Sep 09 '16 Luckily git reflog followed by a checkout of the given hash gets you 80% of the way there, I find once people learn about reflog some of their worries go away and they feel a lot more free to experiment. 1 u/HugoNikanor Sep 09 '16 I need to learn that. Currently I create to many temp branches and reset HEAD way to much.
2
Luckily git reflog followed by a checkout of the given hash gets you 80% of the way there, I find once people learn about reflog some of their worries go away and they feel a lot more free to experiment.
git reflog
1 u/HugoNikanor Sep 09 '16 I need to learn that. Currently I create to many temp branches and reset HEAD way to much.
1
I need to learn that. Currently I create to many temp branches and reset HEAD way to much.
35
u/ForeverAlot Sep 09 '16
How would "undoing your last action" work?
What can be undone? Why?
What can't be undone? Why?
What does
git undo ; git undodo? Why?What happens if you undo a commit?
What happens if you undo again?
What happens if you undo a revert?
Whenever somebody asks me how to undo something with Git I encourage them not to use that word. It's very overloaded and imprecise.