How to rebase one change on top of another change ?

7,505 views
Skip to first unread message

Gouranga Panigrahi

unread,
Feb 24, 2014, 1:29:00 AM2/24/14
to repo-d...@googlegroups.com, david.o...@gmail.com, david.pu...@sonymobile.com

Hi,

I need to rebase the change https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.

Please help me out to achieve the above.

Thanks
Gouranga

David Pursehouse

unread,
Feb 24, 2014, 1:34:57 AM2/24/14
to Gouranga Panigrahi, repo-d...@googlegroups.com, david.o...@gmail.com
On 02/24/2014 03:29 PM, Gouranga Panigrahi wrote:
>
> Hi,
>
> I need to rebase the change
> https://gerrit-review.googlesource.com/#/c/54708/ on top of the change
> https://gerrit-review.googlesource.com/52153.
>

You can't do this from the UI. You need to do it manually in your local
workspace.

Check out change 52153, cherry-pick 54708 on top of it, and then push it
again as a new patch set.

git fetch https://gerrit.googlesource.com/gerrit refs/changes/53/52153/1
&& git checkout FETCH_HEAD

(At this point you will be working on a detached head, so you might want
to create a new branch with `git checkout -b rebasing`)

git fetch https://gerrit.googlesource.com/gerrit refs/changes/08/54708/2
&& git cherry-pick FETCH_HEAD

git push origin HEAD:refs/for/master

Gouranga Panigrahi

unread,
Feb 25, 2014, 1:19:32 AM2/25/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Hi David,

I executed the above commands in my local workspace and got the below error

error: could not apply 873561a... Add a preselect Revision drop down in users preference page
hint: after resolving the conflicts, mark the corrected paths
hint: with 'git add <paths>' or 'git rm <paths>'
hint: and commit the result with 'git commit'

Please tell me how do i fix the above.

Thanks
Gouranga

David Pursehouse

unread,
Feb 25, 2014, 1:30:26 AM2/25/14
to Gouranga Panigrahi, repo-d...@googlegroups.com, david.o...@gmail.com
On 02/25/2014 03:19 PM, Gouranga Panigrahi wrote:
> Hi David,
>
> I executed the above commands in my local workspace and got the below error
>
> error: could not apply 873561a... Add a preselect Revision drop down in
> users preference page
> hint: after resolving the conflicts, mark the corrected paths
> hint: with 'git add <paths>' or 'git rm <paths>'
> hint: and commit the result with 'git commit'
>
> Please tell me how do i fix the above.
>

After resolving the conflicts, mark the corrected paths with 'git add
<paths>' or 'git rm <paths>' and commit the result with 'git commit'.



> Thanks
> Gouranga
>
> On Monday, February 24, 2014 12:04:57 PM UTC+5:30, David Pursehouse wrote:
>
> On 02/24/2014 03:29 PM, Gouranga Panigrahi wrote:
> >
> > Hi,
> >
> > I need to rebase the change
> > https://gerrit-review.googlesource.com/#/c/54708/
> <https://gerrit-review.googlesource.com/#/c/54708/> on top of the
> change
> > https://gerrit-review.googlesource.com/52153
> <https://gerrit-review.googlesource.com/52153>.
> >
>
> You can't do this from the UI. You need to do it manually in your
> local
> workspace.
>
> Check out change 52153, cherry-pick 54708 on top of it, and then
> push it
> again as a new patch set.
>
> git fetch https://gerrit.googlesource.com/gerrit
> <https://gerrit.googlesource.com/gerrit> refs/changes/53/52153/1
> && git checkout FETCH_HEAD
>
> (At this point you will be working on a detached head, so you might
> want
> to create a new branch with `git checkout -b rebasing`)
>
> git fetch https://gerrit.googlesource.com/gerrit
> <https://gerrit.googlesource.com/gerrit> refs/changes/08/54708/2
> && git cherry-pick FETCH_HEAD
>
> git push origin HEAD:refs/for/master
>
> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google
> Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to repo-discuss...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Gouranga Panigrahi

unread,
Feb 25, 2014, 3:22:15 AM2/25/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Thanks David,

The conflicted files in my local workspace are marked as red and each of these files are added with below lines(colored in red).

<<<<<<< HEAD
=======
  private boolean loaded;
  private boolean diffChange;
  private String panel;

>>>>>>> 873561a... Add a preselect Revision drop down in users preference page

I removed these lines but still the files are marked as red.
I am little bit confused with resolving the conflicts. Could you please guide me through it.

Thanks
Gouranga

David Pursehouse

unread,
Feb 25, 2014, 3:29:54 AM2/25/14
to Gouranga Panigrahi, repo-d...@googlegroups.com, david.o...@gmail.com
On 02/25/2014 05:22 PM, Gouranga Panigrahi wrote:
> Thanks David,
>
> The conflicted files in my local workspace are marked as red and each of
> these files are added with below lines(colored in red).
>
> <<<<<<< HEAD
> =======
> private boolean loaded;
> private boolean diffChange;
> private String panel;
>>>>>>>> 873561a... Add a preselect Revision drop down in users preference page
>
> I removed these lines but still the files are marked as red.
> I am little bit confused with resolving the conflicts. Could you please
> guide me through it.
>

The files will be marked as red in `git status` until you `git add` them.

Sorry, but I (and most likely everyone else on this list) do not have
the time to walk you through this in any more detail. It's a pretty
basic git operation and I would expect someone working on Gerrit
development to be able to do it themselves.

If you need more help with it, there is plenty of information available
via a Google search:

https://www.google.com/search?q=git+resolve+conflicts

/David
> > To unsubscribe, email repo-discuss...@googlegroups.com <javascript:>
> > More info at http://groups.google.com/group/repo-discuss?hl=en
> <http://groups.google.com/group/repo-discuss?hl=en>
> >
> > ---
> > You received this message because you are subscribed to the Google
> > Groups "Repo and Gerrit Discussion" group.
> > To unsubscribe from this group and stop receiving emails from it,
> send
> > an email to repo-discuss...@googlegroups.com <javascript:>.
> > For more options, visit https://groups.google.com/groups/opt_out
> <https://groups.google.com/groups/opt_out>.

Gouranga Panigrahi

unread,
Feb 25, 2014, 3:33:16 AM2/25/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Thanks David.

Gouranga Panigrahi

unread,
Mar 11, 2014, 7:02:20 AM3/11/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Hi David,

I am still facing issues while rebasing  https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.

Please help.

David Ostrovsky

unread,
Mar 11, 2014, 7:08:03 AM3/11/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com

On Tuesday, March 11, 2014 12:02:20 PM UTC+1, Gouranga Panigrahi wrote:
Hi David,


every one called David or Dave on this list ;-)
 
I am still facing issues while rebasing  https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.


I fixed the rebasing problem in patch set 5 of this change. Just restore it.

Gouranga Panigrahi

unread,
Mar 11, 2014, 8:33:18 AM3/11/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Hi David,

Could you please refer me the steps that required to restore the patchset 5 of this change ?

David Ostrovsky

unread,
Mar 11, 2014, 8:41:48 AM3/11/14
to repo-d...@googlegroups.com, Gouranga Panigrahi

On Tuesday, March 11, 2014 1:33:18 PM UTC+1, Gouranga Panigrahi wrote:
Hi David,

Could you please refer me the steps that required to restore the patchset 5 of this change ?


git fetch https://gerrit.googlesource.com/gerrit refs/changes/08/54708/5 && git checkout FETCH_HEAD
git push gerrit HEAD:refs/for/master

or whatever your remote name for gerrit is.

Gouranga Panigrahi

unread,
Mar 11, 2014, 8:46:47 AM3/11/14
to repo-d...@googlegroups.com, Gouranga Panigrahi
Thanks David.

Gouranga Panigrahi

unread,
May 15, 2014, 9:30:17 AM5/15/14
to repo-d...@googlegroups.com, Gouranga Panigrahi
Hi,

I am facing issues while rebasing change
https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.
i cloned a fresh copy of source code and then executed the below commands


*git fetch
https://gerrit.googlesource.com/gerrit refs/changes/53/52153/2 && git checkout FETCH_HEAD

*git checkout -b rebasing


*git fetch
https://gerrit.googlesource.com/gerrit refs/changes/08/54708/5 && git cherry-pick FETCH_HEAD

*No conflicts are coming


*git push origin HEAD:refs/for/master


But after uploading the status is merge conflict for the change.
 
So my question is: Is there any way we can check before pushing change, which files are causing the merge conflict
(and which lines in the files are the conflicting ones) so I can work onto resolve it?

Below is output after cherry picking:

[334723@01HW497639 gerrit]$ git fetch https://gerrit.googlesource.com/gerrit refs/changes/08/54708/13 && git cherry-pick FETCH_HEAD
remote: Counting objects: 4567, done
remote: Finding sources: 100% (45/45)
remote: Total 45 (delta 0), reused 20 (delta 0)
Unpacking objects: 100% (45/45), done.
From https://gerrit.googlesource.com/gerrit
 * branch            refs/changes/08/54708/13 -> FETCH_HEAD
[rebasing 7454cd3] Add a Preselect Diff Against drop down in users preference page
 13 files changed, 138 insertions(+), 12 deletions(-)
 create mode 100644 gerrit-server/src/main/java/com/google/gerrit/server/schema/Schema_94.java


Thanks
Gouranga

David Pursehouse

unread,
May 15, 2014, 10:25:41 AM5/15/14
to Gouranga Panigrahi, repo-discuss

On 15 May 2014 22:30, "Gouranga Panigrahi" <goura...@gmail.com> wrote:
>
> Hi,
>
> I am facing issues while rebasing change https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.
> i cloned a fresh copy of source code and then executed the below commands
>
> *git fetch https://gerrit.googlesource.com/gerrit refs/changes/53/52153/2 && git checkout FETCH_HEAD
>

This is probably the problem.  You've checked out the commit that was fetched, and that is likely not based on the head of the master branch.

> *git checkout -b rebasing
>
> *git fetch https://gerrit.googlesource.com/gerrit refs/changes/08/54708/5 && git cherry-pick FETCH_HEAD
>
> *No conflicts are coming
>

After this step do 'git rebase origin/master' and then resolve the conflicts.

> --
> --
> To unsubscribe, email repo-discuss...@googlegroups.com
> More info at http://groups.google.com/group/repo-discuss?hl=en
>
> ---
> You received this message because you are subscribed to the Google Groups "Repo and Gerrit Discussion" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to repo-discuss...@googlegroups.com.

> For more options, visit https://groups.google.com/d/optout.

Gouranga Panigrahi

unread,
May 20, 2014, 5:51:09 AM5/20/14
to repo-d...@googlegroups.com, Gouranga Panigrahi


On Thursday, May 15, 2014 7:55:41 PM UTC+5:30, David Pursehouse wrote:

On 15 May 2014 22:30, "Gouranga Panigrahi" <goura...@gmail.com> wrote:
>
> Hi,
>
> I am facing issues while rebasing change https://gerrit-review.googlesource.com/#/c/54708/ on top of the change https://gerrit-review.googlesource.com/52153.
> i cloned a fresh copy of source code and then executed the below commands
>
> *git fetch https://gerrit.googlesource.com/gerrit refs/changes/53/52153/2 && git checkout FETCH_HEAD
>

This is probably the problem.  You've checked out the commit that was fetched, and that is likely not based on the head of the master branch.

Ok David, so does that mean that I should execute this command instead? :
git fetch https://gerrit.googlesource.com/gerrit refs/changes/53/52153/1 && git checkout FETCH_HEAD
and then continue with rest steps as below.
 

Gouranga Panigrahi

unread,
May 20, 2014, 8:39:59 AM5/20/14
to repo-d...@googlegroups.com, Gouranga Panigrahi, david.o...@gmail.com
Hi David O,

The rebase issue with change 54708 seems to be coming again n again. 
I am executing below steps to rebase 54708 but when pushing the patchset is being uploaded to 52153.
(What is required is: to rebase 54708 on top of 52153) Can you please check my steps and let me know if I am missing something here ?

git fetch https://gerrit.googlesource.com/gerrit refs/changes/53/52153/4 && git checkout FETCH_HEAD
git checkout -b rebasing
git fetch https://gerrit.googlesource.com/gerrit refs/changes/08/54708/5 && git cherry-pick FETCH_HEAD
git rebase origin/master

git push origin HEAD:refs/for/master

Thanks
Gouranga

Magnus Bäck

unread,
May 20, 2014, 8:51:00 AM5/20/14
to repo-d...@googlegroups.com
On Tuesday, May 20, 2014 at 14:39 CEST,
Gouranga Panigrahi <goura...@gmail.com> wrote:

> The rebase issue with change 54708 seems to be coming again n again.
> I am executing below steps to rebase 54708 but when pushing the
> patchset is being uploaded to 52153.
> (What is required is: to rebase 54708 on top of 52153)
> Can you please check my steps and let me know if I am missing
> something here ?
>
> git fetch https://gerrit.googlesource.com/gerrit
> refs/changes/53/52153/4 && git checkout FETCH_HEAD
> git checkout -b rebasing
> git fetch https://gerrit.googlesource.com/gerrit
> refs/changes/08/54708/5 && git cherry-pick FETCH_HEAD
> git rebase origin/master
> git push origin HEAD:refs/for/master

Your rebase operation will rebase the 52153 commit as well,
which explains why Gerrit wants to update that change with
a new patch set when you push your commit.

This is the situation in your repository after the two fetch
operations:

---52153/4----54708/5'
/
-------------------- origin/master

In this situation, 'git rebase origin/master' will create
the following:

---52153/4'----54708/5''
/
-------------------- origin/master

So, simply stop doing that rebase. If you need your change
to be based on newer code than what change 52153 can provide
someone will have to rebase that change for you.

--
Magnus Bäck | Software Engineer, Development Tools
magnu...@sonymobile.com | Sony Mobile Communications

Gouranga Panigrahi

unread,
May 20, 2014, 9:50:55 AM5/20/14
to repo-d...@googlegroups.com, david.o...@gmail.com, david.pu...@sonymobile.com
Thanks Magnus for your input.


Hi David O./David P.,


As suggested by Magnus, can you please help to rebase 54708 on new code of 52153.


Thanks
Gouranga

David Ostrovsky

unread,
May 21, 2014, 5:32:15 PM5/21/14
to repo-d...@googlegroups.com, david.pu...@sonymobile.com

Am Dienstag, 20. Mai 2014 15:50:55 UTC+2 schrieb Gouranga Panigrahi:
Thanks Magnus for your input.


Hi David O./David P.,


As suggested by Magnus, can you please help to rebase 54708 on new code of 52153.

Rebased and resolved conflicts, but i hadn't time to test it.

Gouranga Panigrahi

unread,
May 22, 2014, 2:44:30 AM5/22/14
to repo-d...@googlegroups.com, david.pu...@sonymobile.com
Thanks a lot David O.

Gouranga Panigrahi

unread,
Jun 13, 2014, 5:29:41 AM6/13/14
to repo-d...@googlegroups.com

On Tuesday, May 20, 2014 6:21:00 PM UTC+5:30, Magnus Bäck wrote:
Hi David O/David P,
 
Can you please help in uploading a new patchset(to avoid any conflicts) for the below comment
 
 
Thanks
Gouranga

David Pursehouse

unread,
Jun 13, 2014, 10:22:30 AM6/13/14
to Gouranga Panigrahi, repo-discuss
On Fri, Jun 13, 2014 at 6:29 PM, Gouranga Panigrahi <goura...@gmail.com> wrote:
Hi David O/David P,
 
Can you please help in uploading a new patchset(to avoid any conflicts) for the below comment
 
 

Sorry, no.

I have barely enough time to work on my own Gerrit contributions on top of the work at my day job, so I can't afford to spend time doing your work as well.

You've had plenty of help with this already - don't you think it's about time you were able to do it by yourself?  I don't think it's too much to ask that someone who works on Gerrit is able to do a git rebase.

Reply all
Reply to author
Forward
0 new messages