I’m just showing you this so you will have a reference point and you know what to look for during the rebasing process. If we take a quick look at the current state of the main branch, we will see the history as shown in the screenshot underneath. You will see that Andrei made a great start with this PR and now I am taking over. Everything above that are the commits that hold the changes we want merged into main. The commits marked in red at the bottom of the list are the latest changes on main at that time. Commit history for the RadioButton branch In the screenshot from GitHub Desktop below you can see the current state. It has been sitting there for a while now while main has had several changes added. I have a PR that I am still working on to add a RadioButton to the Xamarin.Forms toolkit. I actually really like the GitHub Desktop client, simple yet effective. To make things a bit more visual I will use a GUI tool. That will show what is actually going on under the hood. While there are some tools that will do it with a great GUI, I will show you how to do it with the command-line. Imagine that the yellow dots are main and the purple ones are your branch/PR. On the left you see a merge, in the middle is your typically branching and on the right you can see a rebase. Have a look at the graphic below which will hopefully make it a bit more clear. After each commit is replayed there is a check if there are conflicts which you should then fix, but more on that later. Then commit by commit your changes are re-added on top of the latest state on main. When you do a Git rebase you take that latest state of the main branch. Since you opened the PR, new commits were added to the main branch. Imagine you want to add commits to the main branch. What will happen during a Git rebase is that the commits you want to add to the codebase are replayed on top of the target branch. This is where things start to get a bit scary, because it involves rewriting history due to force pushing. As you can see, there are a lot of reasons for a rebase. Or your code hooks into new code that is now added in the target branch. Another reason might be that you have just opened the PR at a time where the tests or build were in a bad state. On the Xamarin.Forms repository we might ask you to do a rebase whenever there are conflicts. That will however give a lot of merge commits and isn’t very clean. What you could do is merge the changes from the target branch into your PR branch. These are conflicts between your code changes in the PR and other changes that got merged into the target branch. Meanwhile, development goes on and the branch you are targeting with your PR gets updated. Unfortunately reality is that your PR might be sitting there for a while. You have gathered the courage to open that PR and hope it will get merged soon. The Backstory #įinally, your change is ready for the world to see. So where it says master in the screenshots, you can substitute that for main. Note! In the screenshots the branch is named master I have updated the text to now use main.
0 Comments
Leave a Reply. |