If you know the commitID (hash code) then it's simple. Just use git cherry-pick as @VonC suggested in his answer. You can follow below way to achieve it.
git fetch origin
--> Or change origin with your repo name.
git checkout -b newBranch
--> I am creating a new branch for safety.
git reset --hard origin/branchInServer
--> Now new branch should have changes of branchInServer exactly as it is.
git log --pretty=format:"%h | %an | %ad | %s" --date=iso --graph -30
--> To print last 30 commits in your branch with graph,date,comment etc. Here it should print your friend's commit and overwritten commit (Change 30 if required)
git branch | grep "^*"
--> To make sure the branch.
Now, just think this is your output.
* 1112 User1 "last commit in this branch"
* 2234 User2 "second last commit"
* 3344 User3 "OVERWRITTEN commit"
* 4455 User4 "some commit between"
* 0101 Friend1 "Friends commit"
* 5577 User5 "some commit before"
* 9911 User5 "some commit before"
If this is the output you expect, do the following.
git reset --hard 4455
(To reset to a commit before override)
OR
git reset --hard 9911
(Reset to any commit before and cherry-pick
yours)
git cherry-pick 0101
Note:
If you don't know what count to put to get the git log with your friend's commit, do this.
git log --pretty=format:"%h | %an | %ad | %s" --date=iso --graph | grep "Frend'sName"