News for hackers. Stuff that matters.
Re:Idiot Proof Git by stephen_g on Thursday November 10, 2022 @12:25AM (#33542592)
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.
Re:Idiot Proof Git by arcanemachiner on Thursday November 10, 2022 @12:28AM (#33542613)
git undo -f
Re:Idiot Proof Git by notpushkin on Thursday November 10, 2022 @02:20AM (#33543271)
Since 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.
Re:Idiot Proof Git by ykonstant on Thursday November 10, 2022 @11:36AM (#33549058)
Should also support the gnu long-option, git undo --fuck-up
Re:Idiot Proof Git by est on Thursday November 10, 2022 @01:54AM (#33543124)
> 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.

Re:Idiot Proof Git by hoseja on Thursday November 10, 2022 @04:53AM (#33544344)
You can also `revert` which, while staying in history, needs no warning.
Re:Idiot Proof Git by stephen_g on Friday November 11, 2022 @12:35AM (#33557642)
Assuming 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).
Re:Idiot Proof Git by jononor on Thursday November 10, 2022 @03:50AM (#33543872)
If 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".

Re:Idiot Proof Git by stephen_g on Friday November 11, 2022 @12:32AM (#33557623)
The 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.