Question
Git: Why does "--force-with-lease" with an explicit SHA work differently than the implicit version?
While using "git push --force-with-lease", I encountered a behavior that I do not understand. According to the documentation (https://git-scm.com/docs/git-push), you can specify a SHA-1 value explicitly on the command line, or you can leave it out, in which case git will be "requiring its current value to be the same as the remote-tracking branch we have for it".
Specifically, if I do git push --force-with-lease=preflight/myname origin develop:preflight/myname
, git says Updates were rejected because the tip of the remote-tracking branch ...
But if I look up the SHA of .git/refs/remotes/origin/preflight/myname explicitly (let's say it is 7528290003ef5b36f9f6446c91cb4a3ddb20c0c2) and then do git push --force-with-lease=preflight/myname:7528290003ef5b36f9f6446c91cb4a3ddb20c0c2 origin develop:preflight/myname
, git pushes successfully.
I would have expected both calls to result in the same behavior. What am I missing?