If your master branch of your fork has diverged from upstream master you can check your master by typing
git checkout master
git fetch upstream master
git merge --ff-only upstream/master # if this fails your master is not the same as upstream i.e. it won't fast-forward
To clean up your master try (Option 2 is simpler, Option 1 downloads less)
# (Option 1) Fix master from point of divergence
#WARNING: you will lose your changes to master
git checkout master
git fetch upstream master
git reset --hard <commit_where_it_diverges>
git merge --ff-only upstream/master # if this fails you have found the point far back enough in time before the divergence
git push --force origin master #This step is only required if you pushed your 'mess' to origin ;)
#(Option 2) Fix by deleting master and starting again with a fresh copy
#Warning this will delete any changes you have made on master
git checkout upstream/master
git branch -D master
git branch master
git checkout master
git push --force origin master #This step is only required if you pushed your 'mess' to origin ;)
Also useful comamnds are
make clean # Do this in the root build dir
git clean -d -f -x # get rid of all not git files (be warned you could lose work if you haven't committed those changes