简体   繁体   中英

Rebasing current patchset in Gerrit onto another branch

At the project I work on there are two branches: Main and Feature. I have worked on Feature branch and pushed to Gerrit and got some reviews(I have 10 patchsets at the moment on the Feature branch). Now I want to rebase the Feature branch onto the Main branch but also keep the history of reviews and patchsets(so not like a cherry pick which picks just the last commit and does not keep history). Is it possible to do this? I know I can do a merge but will this keep the history of the review that was done on the Feauture branch when I will push the new commit(after merge) to Main?

Thanks for reading!

The correct way to bring the feature to the main branch is to make a merge. Doing a merge is very simple and yes... you'll keep all the history of the review on the Feature branch.

Do the following:

  1. Finish the review work on Feature branch, approve and submit the change
  2. Checkout the Main branch in your local repository
  3. Fetch (git fetch) and merge the Feature branch (git merge origin/Feature)
  4. If needed, solve the conflicts (git mergetool)
  5. Push to the Main branch to review (git push origin HEAD:refs/for/Main)
  6. Review, approve and submit the change

You can move your change from the Feature branch to the master branch. This will not change the parent but after having moved it your can rebase your change on the tip of the master.

This is almost like a cherry-pick but you keep the history在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM