0

I have a situation where I need to create my branch(Say BranchB) out of a different branch(say BranchA) that is not merged yet. BranchA is up for gerrit review and modification goes on everytime in that branch.

If I go to gerrit UI, I am able to see the download dropdown on topmost righthand corner. Clicking which gives me an option to checkout. The command is something like,

git fetch ssh://**@**gerrit..****:12345/project-repo refs/changes/02/89765/15 && git checkout FETCH_HEAD

Using this I created my own local branch i.e BranchB and I also have the code from BranchA. Now the other person who works on BranchA, posted some updates which is necessary for me as well and I wanted to do git pull --rebase. But it didn't work. It asks me to specify the branch I want to pull. I tried doing a git fetch --all to update all remote branches in my local and tried to do git pull --rebase again. Didn't work either. What is the solution and the ideal way to create branches in situations like this.

Deca
  • 1,155
  • 1
  • 10
  • 19

1 Answers1

0

While changes aren't merged they are in special (magical) branches like "refs/changes/02/89765/15" which are not fetched by regular "git fetch" command. But you can fetch and rebase it with the following commands:

git fetch origin refs/changes/02/89765/15
git rebase FETCH_HEAD

The "15" at the end shows that this is the patchset 15 of the change.

  • It gave me an error while executing first fetch itself git fetch refs/changes/02/124902/20 Error is:- fatal: 'refs/changes/02/124902/20' does not appear to be a git repository fatal: The remote end hung up unexpectedly – Deca Jan 22 '18 at 06:46
  • Sorry, the "origin" was missing... I fixed the answer. – Marcelo Ávila de Oliveira Jan 22 '18 at 10:21