I think you like to use
git checkout -p
In your case
git checkout dev
git checkout -p test somecode.js
And you can interactively apply the diffs.
I think you like to use
git checkout -p
In your case
git checkout dev
git checkout -p test somecode.js
And you can interactively apply the diffs.