From: Jacob Keller Date: Sat, 08 Apr 2017 08:25:43 GMT Subject: Re: Tools that do an automatic fetch defeat "git push --force-with-lease" Message-ID: In-Reply-To: <1491617750.2149.10.camel@mattmccutchen.net> On Fri, Apr 7, 2017 at 7:15 PM, Matt McCutchen wrote: > When I'm rewriting history, "git push --force-with-lease" is a nice > safeguard compared to "git push --force", but it still assumes the > remote-tracking ref gives the old state the user wants to overwrite. > Tools that do an implicit fetch, assuming it to be a safe operation, > may break this assumption. In the worst case, Visual Studio Code does > an automatic fetch every 3 minutes by default [1], making > --force-with-lease pretty much reduce to --force. > Isn't the point of force-with-lease to actually record a "commit" id, and not pass it a branch name, but actually the sha1 you intend the remote server to be at? Sure if you happen to pass it a branch or remote name it will interpret it for yuou, but you should be able to do something like current=$(git rev-parse origin/branch) git push --force-with-lease=$current and this will work regardless of when if if you fetch in between? Thanks, Jake