Reputation: 1201
I have been working with git from quite while. But whenever there is a situation where I have to create new branch and merge it, I personally avoid it because I have faced a lot of issues while doing it for one of my project. Which was ruined after git merge, and project got a ton of bugs.
So now I want to understand git merge or rebase.
I heard of rebase but still not using it thinking that it will have same effect as git merge do :p
Lets take an example
I am working on master branch and project is completed. Now I want to update the project to whole new layout as per new design.
So I have created a branch called layout. And I am done integrating new template in layout branch and add new feature as well.
This is the new feature I want to add in my master branch without getting the new template.
How can I achieve this.
Upvotes: 0
Views: 131
Reputation: 336
You're going to have conflicts with both merge and rebase as well, that's not the point of rebase.
The key here is to merge (or rebase) often, possibly multiple times a day. That way you'll only have to deal with fairly small number of conflicts which are usually easy to solve. On the other hand if you have a long running branch, without merging it for a substantial amount of time, you'll have so many conflicts in multiple files that it'll be impossible to deal with them, and you'll need a huge amount of luck not doing something wrong.
So use short-lived branches and merge at least once a day.
The question is then if you only have short-lived branches how do you add a larger feature, e.g. a new layout as you mentioned.
One solution is to use feature toggles: merge the new feature into the master branch even if the feature is not ready to be shown to the users, and use a feature toggle to hide the feature. Once you decide the feature is good enough just turn on the feature toggle and the new feature is now visible for the user.
More on feature toggles: https://martinfowler.com/articles/feature-toggles.html
You can even use a hosted service for that if you want: https://configcat.com/
Upvotes: 2