On Thu, 3 Sep 2015 19:16:23 +0300
Ram Rachum <ram.rac...@gmail.com> wrote:

[...]
> > Yes, since some version `git push` learned the --force-with-lease
> > command-line option which does just what you want: makes sure the
> > tip of the existing branch is exactly what you expect it to be.
> 
> I was very happy to see this portion of your message because I
> figured you found a solution to my problem, but I tried it now and it
> didn't work. It pushes alright, but it happily runs over other
> changes that were pushed to the remote.
> 
> I had a situation like this: http://i.imgur.com/sn8oScu.jpg
> 
> Then ran this:
> 
> $ git push origin test-lease --force-with-lease
> Counting objects: 2, done.
> Delta compression using up to 4 threads.
> Compressing objects: 100% (2/2), done.
> Writing objects: 100% (2/2), 244 bytes | 0 bytes/s, done.
> Total 2 (delta 1), reused 0 (delta 0)
> To [REDACTED]
>    f7127f4..282393a  test-lease -> test-lease
> 
> Then I got this: http://i.imgur.com/7iq5qRJ.jpg
> 
> So as you can see, the commit  f7127 was thrown away.
> 
> Perhaps I misunderstood how `--force-with-lease` is supposed to work?

The documentation says that the unadorned --force-with-lease looks at
the remote-tracking branch for the target ref (a branch in your case),
if this exists, and requires the tip of the target ref to be the same
as the tip of this remote-tracking branch.

IOW, if you're pushing to "test-lease" with plain --force-with-lease,
`git push` will try to locate the "remotes/origin/test-lease" branch
and then require that the remote "test-lease" branch points to the same
commit your "remotes/origin/test-lease" points to.

This means that if you did rebase your local "test-lease" and then
did `git fetch`, you've updated your "remotes/origin/test-lease"
with the current "upstream" tip commit of that branch and the check
passed when you pushed.

So, could you somehow verify that?

You could also try the two argument form of --force-with-lease.

-- 
You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to