I recently ran into a situation where I needed to sync one of my branches with the files that were located on the master branch, which was ahead. Here’s how I went about it:

Please note that the branch that I wanted to sync to did not contain files or directories that were not in the master branch at one point in time.

  1. Switch to the branch that you want to sync with the master branch:

    git checkout nameOfBranch

  2. Merge the master branch with the branch you are currently on:

    git merge origin/master

  3. Push your changes to your branch:

    git push origin nameOfBranch