Home > Software design >  How to rebase local branch on gerrit change?
How to rebase local branch on gerrit change?

Time:12-22

I have a local commit that is based on a gerrit change (not yet submitted). I created my local branch by fetching the gerrit change and creating a new branch from that.

Now the gerrit change has a new patchset uploaded, so I'd like to rebase my local change too. How can I do that?

Tried to fetch the change

git fetch origin refs/changes/69/111569/10

but I couldn't reference it when rebasing.

CodePudding user response:

By "creating a new branch from that", I assume it's also a local branch, right?

Check the commit sha1 value of the local commit. Suppose it's abc123.

Reset your local branch to the latest patchset first. Is it refs/changes/69/111569/10? If so,

git fetch origin refs/changes/69/111569/10 && git reset FETCH_HEAD --hard

Note that git reset --hard wipes your uncommitted changes. Stash them if any.

Cherry-pick the local commit to the updated local branch.

git cherry-pick abc123
  • Related