This worked for me perfectly:
1.git stash
to save your local modifications
If you want to discard changes
git clean -df
git checkout -- .
git clean removes all untracked files (warning: while it won't delete ignored files mentioned directly in .gitignore, it may delete ignored files residing in folders) and git checkout clears all unstaged changes.
2.git checkout master
to switch to the main branch (Assuming you want to use master)
3.git pull
to pull last commit from master branch
4.git status
in order to check everything looks great
On branch master
Your branch is up-to-date with 'origin/master'.