threads / discuss / 43360

Re: branch rebase and push

Subject: Re: branch rebase and push

## tl;dr

4 messages between Dec 19, 2006 and Dec 19, 2006.

replies: 3people: 3as markdown or json

SungHyun Nam· Dec 19, 2006, 03:39 UTC · lore

branch rebase and push

Hello,
Can I push a branch after rebase?
I got a error message:
   error: remote 'refs/heads/br' is not a strict subset of local ref
   'refs/heads/br'. maybe you are not up-to-date and need to pull first?
It worked fine if I did:
  $ git checkout -b br
  $ git pull . master
  $ git checkout master
  $ git pull
  $ git push
But I got above error message if I did:
  $ git checkout br
  $ git rebase master
  $ git checkout master
  $ git pull
  $ git push

Thanks. namsh

Jakub Narebski· Dec 19, 2006, 09:57 UTC · re: SungHyun Nam · lore
SungHyun Nam wrote:
Show 18 quoted lines
> Can I push a branch after rebase?
> I got a error message:
>    error: remote 'refs/heads/br' is not a strict subset of local ref
>    'refs/heads/br'. maybe you are not up-to-date and need to pull first?
> 
> It worked fine if I did:
>   $ git checkout -b br
>   $ git pull . master
>   $ git checkout master
>   $ git pull
>   $ git push
> 
> But I got above error message if I did:
>   $ git checkout br
>   $ git rebase master
>   $ git checkout master
>   $ git pull
>   $ git push
The problem you have is with _push_, not branch, I think.

Does repository you pull from has rebased branch 'br'? If yes, is it pulled with + in pull/fetch line? Perhaps (but read documentation first, please) "git push --force" is what you want, provided that other side doesn't forbid non fast-forward pushes.

Bu you usually don't rebase published branch (don't change history of published branch). Equivalently, you don't publish rebased branch until it is ready (or merged in ;-).

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Jakub Narebski· Dec 19, 2006, 11:58 UTC · lore
SungHyun Nam wrote:
> I'm sorry... but could you teach me how I publish the rebased branch?
> I think Junio does it for 'pu' branch.
> Is there recommended workflow? I cannot find.

Either have "Push:+refs/heads/br:refs/heads/br" in your .git/remotes/<name> file, or it's equivalent config file version, with '+' denoting that this branch sometimes does not fast-forward.

Or use git push with --force option when you had rebased.

And of course the server you push to has to not have config variable receive.denyNonFastForwards set to true.

-- 
Jakub Narebski
Johannes Schindelin· Dec 19, 2006, 12:13 UTC · re: Jakub Narebski · lore
Hi,
On Tue, 19 Dec 2006, Jakub Narebski wrote:
Show 15 quoted lines
> SungHyun Nam wrote:
> 
> > I'm sorry... but could you teach me how I publish the rebased branch?
> > I think Junio does it for 'pu' branch.
> > Is there recommended workflow? I cannot find.
> 
> Either have "Push:+refs/heads/br:refs/heads/br" in your
> .git/remotes/<name> file, or it's equivalent config file
> version, with '+' denoting that this branch sometimes does
> not fast-forward.
> 
> Or use git push with --force option when you had rebased.
> 
> And of course the server you push to has to not have config variable 
> receive.denyNonFastForwards set to true.

If that is the case, there is a work-around, which happens to be also nice to tracking parties:

	$ git pull -s ours <remote> <branch>
	$ git push <remote> <branch>

The disadvantage (which I'd argue is actually an advantage) is that you do not lose history. After all: "those who do not learn from history are doomed to repeat it".

Ciao, Dscho

← back to recent threads