Now you have detached the head, detached HEAD means you are no longer on that branch. If you need to delete the changes associated with detached HEAD, you need to check out the branch you were on using
git checkout master
Instead of deleting the file you just do
git checkout --path/to/file
This will restore the file to the state, which is in the index.
And to keep the changes associated with detached HEAD
git log -n 1 // to display the most recent commit on the detached HEAD and copy the commit hash.
git checkout master
git branch tmp <commit-hash> // to save changes in a new branch named tmp.
To incorporate the changes you made into a master
git merge tmp // form the master branch
Make sure that you should be on the master branch after running git checkout master.