Current working branch:
git branch
* master
Working on a different branch:
git checkout -b ANOTHER_BRANCH
Switched to a new branch 'ANOTHER_BRANCH'
Check if there are some new commits on master:
git checkout master
git pull
Merge changes
The easiest approach for merging the changes would be:
git checkout ANOTHER_BRANCH
git merge master
If there are differences, then merge will apply the commits to the top of ANOTHER_BRANCH and create a new merge commit. Otherwise, the merge will be resolved by a fast-forward.
Rebase
git checkout ANOTHER_BRANCH
git rebase master
Rebase moves all diverging commits of ANOTHER_BRANCH to the top. The diverging commits will have new hashes because history will be rewritten. Accordingly, if you’ve previously pushed your feature branch to remote, then the only way to update it is with force push.