![]() ![]() Let’s learn about it today.Īs developers, we work with Git often. ![]() And Git checkout remote branch makes it easier to collaborate and review. This is why we have to use cherry-pick, so we can specify the point at which we break off our bugfix branch to reattach the commits to v1.0.Īt this point, we can merge changes upstream like I described in the original post: # Merge v1.0 into v2.Git is one of the most useful tools for developers and development teams. If we use rebase, it attempts to find all commits on bugfix going back to v1.0, which in our case is pretty much all the recent ones. The reason for using cherry-pick here is that rebase is good at moving changes upstream, but bad at moving changes downstream. What this means is "Apply all the commits made on bugfix since it was branched off devel to v1.0" # These commits are now on v1.0, so we can delete the bugfix branch # Cherry-pick the bugfix commits and apply them onto v1.0 Let's say that bugfix was branched of the devel branch: # switch to v1.0 NB: An older version of this comment initially described using rebase to do this, but rebasing isn't the correct tool for the jobĮdit: I've amended the original comment to fix the mistakes.Ĭoming back to this, I made a mistake! To apply all the bugfix commits onto v1, the command looks like this. Then, we can merge the changes forward as described above. Git cherry-pick devel.bugfix These commits are now on v1.0, so we can delete the bugfix branch Git switch v1.0 Cherry-pick the bugfix commits and apply them onto v1.0 We use devel here since that's where we started the bugfix Lets say you developed the bugfix on devel: ![]() If you already developed the bugfix on a newer version, we can backport it to the version where the problem first occurred using cherry-pick. What happens if we already developed the bugfix on a newer branch? ``` git log B.A will display all commits on branch A that AREN'T on branch B If you've done everything correctly, this output should be empty Because every commit on branch v1.0 is on branch v2.0 In other words, v2.0 is a superset of v1.0įor more information, look at the documentation for ranges and revisions in git. When exploring the history of your repository, it's easy to verify that newer versions have every commit and bug fix of older versions: This is good because it keeps a record that someone looked at these changes, and took the time to integrate them into every version. This means that any commit that exists on v1.0, also exists on v2.0 and v3.0!Īnd even if a change is no longer relevant for a new version (because the code was changed so drastically the bug never exists, for example), then when doing the merge, you can simply select the code from the newer version. This has the added benefit that each new version is a superset of the previous version. Git merge bugfix This will probably be a fast-forward merge if no one else has been working on v1.0 ``` Create bugfix branch, develop bugfix. # Let's say the problem occurred way back in version 1.0
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |