We have two main ways to incorporate our branches: merge or rebase.
Look at the picture, it is a basic example.
- Nonlinear history of commits
- Works badly in big team
- Create a new commit (merge commit)
- The first commit for reset is general commit
git co master & git merge feature
What does merge do?
- Finds general
- Takes last changes from last commits in branches
- Creates a new commit (merge commit)
The first commit for undoing changes is a general commit, and this is the main problem, in my opinion. However, we can return to the specific commit, but it is not very convenient.
Advantages of rebase:
- Conflicts occur less frequently
- Conflicts occur for an each commit in particular
- Clean history
features rabase master
What does rebase do?
- Deletes commit in feature
- Changes parent commit to the last commit in master
- Copies all the changes into new commits with new parent
git checkout master & git merge feature
Merge works with fast forward strategy in this case.
GIT FLOW or the way I do it
1 Create feature-branch from master
2 Do many small commits
3 Do rebase from master more frequently
4 Do rebase from master when work is done
5 Checkout in master
6 Do master merge feature-branch
7 Git push (First you have to finish the work, then you can push)
8 Delete feature-branch
Now you have a few thoughts about merge and rebase. If you are familiar with git, I advice you to use rebase.If you don`t know how it works, please use merge. Clean history is not really important if your project could be on fire 🙂