I need to restore a folder I deleted in Git but I am having trouble doing it so I end up with the folder in the correct branch.
I have done:
git checkout commit_id -- /path/to/folder
This just puts the repo in a detached HEAD state and I am unsure how to get the files back to the master branch?
I also tried:
git checkout -b restore commit_id -- /path/to/folder
This created a new branch, but when I tried to merge that branch into master it said it was "Already up to date".
Running the below didn't work either as per the apparent duplicate question, this simply switched me to the other branch again:
git checkout myBranch -- /path/to/folder
Why is this so hard to do? What is the correct way?