Git rebase operation in sourcetree

Time:2022-6-10

Recently, Gerrit was used as a review method in the project (the previous project was small and had not been exposed to this kind of code review), resulting in some changes in the previous code submission process

Before (this is one of my submission methods, which is completely completed on sourcetree)

  • 1.local_ Branch development code,
  • 2.local_ Master pull origin_ The latest code submitted by the master,
  • 3. set local_ Branch merge to local_ Master branch,
  • 4.local_ Push master to origin_ master,

When it comes to review, I need to re sort out the code submission process

  • 1.local_ Branch development code, (unchanged)
  • 2.local_ Branch pulls the latest code (if this branch is only used by you, this step is ignored)
  • 3. this step is the protagonist. We need to modify the local_ The source of the branch (that is, the so-called base change, that is, the GIT rebase operation),

Just look at the screenshot

When rebase is not performed, it is based onfeat(it can be understood as an earlier master version)

Git rebase operation in sourcetree

Screenshot 2.37.48 PM, October 27, 2021 png

After rebase operation, you can see that theHeight and weight(it can be understood as the latest master version)

Git rebase operation in sourcetree

Screenshot 2.39.47 PM, October 27, 2021 png

Specific steps:

Git rebase operation in sourcetree

WechatIMG18.jpeg

Git rebase operation in sourcetree

WechatIMG19.jpeg

Here, click square to merge the first submission and the second submission into one code submission

Git rebase operation in sourcetree

Screenshot 2.40.20 PM, October 27, 2021 png

At this time, the code we developed and the latest code of origin are merged into the current branch. At this time, we need to review my code through Gerrit
Input at terminalgit push origin HEAD:refs/for/master(head represents the branch you are currently sitting on. You can also write a specific branch name. You are used to using source. I think it will be more convenient to replace it with head here.)
You’ll get a Gerrit address

Git rebase operation in sourcetree

WechatIMG20.jpeg

The following is a small partner to help you audit the code. After you pass the audit, you can submit it yourself!
(the company gave a set of GIT operation steps. Because I was used to using sourcetree, I studied it by comparison.)
How to connect specific projects to Gerrit? Let’s continue to learn later