For simplicity, let's create a repository with two commits only:
mkdir somedir
cd somedir
git init
echo hello > somefile
git add somefile
git commit -m 'first'
echo world >> somefile
git commit -am 'second'
For clarity, at this point git log --oneline returns
fd5b1ce (HEAD -> master) second
f621ab9 first
What I want to get to is the following
xxxxxxx (HEAD -> master) third
fd5b1ce second
f621ab9 first
with somefile in third having the same content as somefile in first.
I could certainly do git cherry-pick master~ (here master is fd5b1ce) and resolve the conflict totally in favour of first, but maybe there's a cleaner approach?
That seems a good fit for git revert
But that apply to all files from second commit (being reverted)
If you need to revert only one file, use
git restore.