Gits branching model makes it a powerful tool You must merge the changes from one branch to another while working with it However how to do it can be different

There are a couple ways to go about this 

 Git Merge 

When you merge Branch A into Branch B git merge Git creates a new merge commit This commit has two parents one from each branch symbolizing the confluence of histories Its a nondestructive operation preserving the exact history of your project  warts and all Merges are especially helpful in disciplines such as design where maintaining the integrity of changes and their chronological order is important However merge commits tend to clutter the history making it difficult to trace a line of development

 Rebase

When you rebase Branch A onto Branch B git rebase youre essentially saying Lets pretend these changes from Branch A were made on top of the latest changes in Branch B Rebase rewrites the project history by creating new commits for each commit in the original branch This will give you a much cleaner straightline history However if multiple people are working on the same branch rebasing could be problematic Rebasing rewrites history and will be complicated if others have pulled or pushed the original branch

 When to use them

Use merge to preserve the complete history especially on shared branches or for collaborative work Its best for feature branches to merge into a main or develop branch

 Use rebase for personal branches or to keep a clean linear history for easy change tracking Remember to rebase locally and avoid pushing rebased branches to shared repositories Also do not rebase public history If your branch is shared with others rebasing can rewrite history in a way that is disruptive and confusing to your collaborators.