On the off chance that the remote machine is a github repository,
-
First use Github’s Events API to retrieve the commit SHA.
curl https://api.github.com/repos/<user>/<repo>/events
-
Identify the SHA of the orphan commit-id that no longer exists in any branch.
-
Next, use Github’s Refs API to create a new branch pointing to the orphan commit.
curl -i -H "Accept: application/json" -H "Content-Type: application/json" -X POST -d '{"ref":"refs/heads/D-commit", "sha":"<orphan-commit-id>"}' https://api.github.com/repos/<user>/<repo>/git/refs
Replace
<orphan-commit-id>
in the above command with the SHA identified in step 2. -
Finally
git fetch
the newly created branch into your local repository.
From there you can cherry-pick or merge the commit(s) back into your work.
Check out this article for an actual example.