If you share your branch with someone else (ie: a public branch), you should avoid rebasing as it may be confusing and a bit risky or do it really carefully and warn your team mates. Note: it is highly recommanded to rebase only on private branches. Moreover, your commits on the feature branch can be splitted and kind of "lost" between commits from master. Indeed, let's imagine that the master branch regularly receives new commits and you need them: you'll need to do multiple merges that will create one new commit for each merge. if you don't care about your git history. We are then in a classic situation where your branch is no more up-to-date with master but you need those 2 new commits from master in your feature branch. And the master branch now contains 2 new commits (in blue). On your feature branch you've added 3 new commits (in green). I'll try to explain you what are the main differences and how to use them.įirst of all, let's say that we are in the following situation : we have a master branch which is public and we've created a feature branch from it (the common commits are in white on the image). When it comes to merging 1 branch in another, you have 2 common solutions : git merge or git rebase. If you want to find the source of a bug, it's much more easier if the commit contains all the changes done related to this bug rather than looking through multiple small commits. If you look at the commits of a merge request, it's much more easier to understand how (the steps) the feature has been developed if it's not polluated by unnecessary commits. When it comes to read your git history, it's important to find easily what you're looking for and also to be able to fix it quickly.įor example if you need to revert a feature, I'm pretty sure that you'd like to revert only one commit (same for cherry-picks). Through this article, i'll present you some easy git commands that will help you. If you're working on a project with a lot of people, it's important to get a clean and clear git history.
0 Comments
Leave a Reply. |