On Thu, 3 Sep 2015 05:17:34 -0700 (PDT)
Ram Rachum <ram.rac...@gmail.com> wrote:

> I've been using Git for years, but only recently I started working
> for a big company where they use `git rebase` to maintain a linear
> history.
> One problem I have with this is that when I rebase a branch, I can't
> push it to the remote again, I have to use `--force` because the
> remote has a different history, before the rebase.
> I don't like this because using `--force` means that if there were
> more commits in that remote that weren't pulled, they'd be
> garbage-collected!

Well, not really.  They normally will become inaccessible first.
And if the remote has the reflog enabled (it's disabled by default in
bare repositories) the original tip of the branch you overwrote will be
accessible for quite long.

> Is there a way to avoid this? (Aside from pre-checking manually on
> the repo using `git fetch`.) I want something like `push --force`
> except it doesn't discard actual commits, only commits that have been
> reordered due to rebasing. 

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.

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