Easy merging without switching the branch

Git merge without branch checkout

Posted by on September 30, 2015 Easy merging without switching the branch

TL;DR

Replace example with your target branch!

git fetch origin
git fetch origin example:example
git merge example

Problem

Your team is using git and your team mate implemented a new method to a class. You need the current changes, which must not be published to master branch. Follow these steps:

Solution

Fetch all branches

git fetch origin

Fetch changes from specific branch

git fetch origin example:example

Merge changes from specific branch

git merge example