Say the branch in which you were working was : master
git add -A
git commit -m "added few changes"
commit hash = 5e108f2
you added your work and then committed it. But then realised you forgot to pull.Now:
git checkout -b newtry master
// git checkout newtry -->optional : try without this
git branch -d master /git branch -D master (force delete)
git pull origin master
git checkout master
git cherry-pick 5e108f2
git push origin master
git branch -d newtry/git branch -D newtry
this is great