Add force option --force-with-lease
Git push --force overwrites a remote branch with your local branch.
Git push --force-with-lease is a safer option that will not overwrite any work on the remote branch if more commits were added to the remote branch (by another team-member or coworker or what have you). It ensures you do not overwrite someone elses work by force pushing.
As a user, I want GitKraken to support using --force-with-lease with a checkbox.
Under consideration Suggested by: jeremy simmons • Upvoted: 08 Mar • Comments: 11
Force with lease could be the default behavior. Only when it fails GitKraken could ask if you still want to do a Force push.
Exactly like "pull" that has multiple choices, "push" should have "force" and "force-with-lease"
This would be immensely helpful given the way we use git on our team
Agreed with Matteo's suggestion, have "push" with a drop-down option in the gui.
100% Agreed. Gitkraken should not contribute to work being lost on a branch if it does not need to.
Please add this! You could add it as another button in the force dialog:
1. I push a rebased commit
2. Popup has a "Force Push With Lease" option
ex. 'feature/foo' is behind 'origin/feature/foo'. Update your branch by doing a pull. [Pull (fast forward if possible)] [Force Push] [Force Push With Lease] [Cancel]
3. Now we are safe!
Force with lease is not _always_ safe. See https://stackoverflow.com/questions/59309402/is-git-push-force-with-lease-always-safe
Especially since GitKraken continually does `git fetch` in the background, using lease will often give a false sense of security because the local remote has already been updated to match the actual remote. Using it by default for all pushed would be a bad idea.
What I'd like to see some work to streamline the rebase workflow - right now, a rebase always requires clicking the scary red "Force Push" button to update the remote branch. Junior devs always screw this up at first.
I think the proper fix would be an option to change the default Push mode to use `--force-with-lease --force-if-includes` which I _think_ should be safe (needs some experimentation).
Absolute +1 for Nate's approach. Granted, not perfectly safe as Francis pointed out, but safe enough for most use cases. (And I'm pretty sure that Francis misunderstood this, thinking that Force with Lease would be the default even before the point of where a force push is necessary at all - which is not how this would be done.)
Please just give us the option (e.g. like Nate describes). It doesn't need to be the default.
preferably force-with-lease as default force option.
I'm in favor of giving power to the end-user, but many people need to be protected from themselves.
an extra checkbox to check goes a long way in making people think.
--force-with-lease should be default. If nothing else, it would still solve the problem of the "window" where someone may have force-pushed new changes to a branch but GitKraken hasn't yet done it's own auto-fetch yet to surface that information to the user.
IMPORTANT: For maximum safety, GitKraken should block auto-fetch anytime a push dialog confirmation is displayed.
I'm of the opinion that a true "force push" isn't something a human should ever need to do. It's a tool that's generally best reserved for automated tools working within constrains where-in they can make safe assumptions that they intend to override the behavior of other automations (for sake of avoiding cascading failures). A human, however, can and should _always_ fetch to resolve a force-push failure. Therefore, --force-with-lease can and should be the default setting, and no option to use --force from a User Driven UI is necessary. (and force push from command line is easy to do)