People sometimes push things they don't mean to. Depending on the workflow and environment, that can be anywhere between a trivial nuisance to an embarrassing and awkward cleanup. It would seem handy to me to have a --confirm option to git-push (and 'core.confirm-push' to turn it on be default), that would have the following behavior: * An initial --dry-run pass is done but with more verbosity - for updates of existing references, it would show what commits were being added or removed in a one-line format. * The user is prompted if they want to proceed * If the user agrees, then the push is run without --dry-run I've attached a mockup of this as a porcelain 'git safe-push'. (Done not using 'git push --porcelain' because I wanted it to work with existing released Git versions. I was hoping to be able to do 'git config alias.push safe-push', but no facility for interactive only aliases...) I think this wouldn't be too hard to add to 'git push', though I haven't tried to code it. Yes, it's not atomic without protocol changes - I think that's OK: - If the push isn't being forced intermediate ref updates will be caught as a non-fast-forward in the second pass. - If the push is being forced, you might overwrite someone else's push anyways even without --confirm. Thoughts on whether this makes sense as an addition? - Owen
Attachment:
git-safe-push
Description: application/shellscript