5 ms·
That's not a bad idea. Pushed wrong is pretty hard to recover from (since you often aren't allowed to rewrite history on the remote), so I don't think there cou
by stephen_g 4y ago
That's not a bad idea. Pushed wrong is pretty hard to recover from (since you often aren't allowed to rewrite history on the remote), so I don't think there could be an easy 'undo' action for that, but the other ones could potentially be done.
- arcanemachiner 4y agogit undo -f
- notpushkin 4y agoSince we're talking about beginners (dare I say, newbies), I think adding this flag would just make them use it all the time. Perhaps just for this command we should only allow --force-remote, so that they have to (1) type it out explicitly and (2) think about what exactly they're doing.
- ykonstant 4y agoShould also support the gnu long-option, git undo --fuck-up
- est 4y ago> since you often aren't allowed to rewrite history on the remote For dev branches it's easy, `git reset --hard` on local then `git push -f` again. This command combination is not that intuitive for beginners. I agree this action is sometimes hard to recover e.g. on protected branch, so a warning must be given to the user.
- hoseja 4y agoYou can also `revert` which, while staying in history, needs no warning.
- stephen_g 4y agoAssuming your remote allows you to force push. Also you need to specify where to reset to because 'git reset --hard' will just reset you to HEAD, so you actually need to do 'git reset --hard HEAD~' (usually I don't use --hard for this either because often there's some work I want to keep from the commit).
- jononor 4y agoIf the result of the undo is that the remote branch (say main) is back at the point where it was just before, then that is actually a kind of change one could allow? As it does not rewrite history, just reset to previous point in time. But to really support this well, I think git would need a git commit object which means "reset to previous state".
- stephen_g 4y agoThe issue is if somebody else has pulled the remote branch and then you remove the commit, suddenly their branch and yours doesn't match. And then they can't push without massaging it. I hate revert commits but often you have to do them if you make a mistake because usually force pushes will be disabled on master for that reason.