0

I started a git project A, and cloned another git project B into it.
I cluelessly didn't think that it would stay it's own project because it showed up in git status commands.

I changed it and committed, but I don't know where my commits went.
When I check my github page it shows simply a commit ID for the project.

I deleted the B folder, thinking the link would remain in git history, but not it's gone - the folder is not in the trash, and I'm worried I've lost my changes.

I can download the original repo again, but it won't have my changes and I don't know how to get them.

I've checked out old commits when it still existed.
Any ideas how to get them back?

CodeWizard
  • 128,036
  • 21
  • 144
  • 167
Jono
  • 3,393
  • 6
  • 33
  • 48

1 Answers1

0

Any ideas how to get them back?

Yep. If you have those commits you can simply follow one of the options described here and get your data back.

How to move HEAD back to a previous location? (Detached head)

You have several options which you can use and some of them are described in the above post.


Once the data is recovered what do do now?

Once you have retained your data back use the git cherry-pick command to add the desired commits to the desired branch and then commit them


I changed it and committed, but I don't know where my commits went.

If you have committed your commit is not lost and can be recovered as long as you did not deleted the branch which you committed to. You dont have to push the branch you can have it locally as well.

Use the git reflog as explained in the above link to find the exact commit(s) that you need.

Community
  • 1
  • 1
CodeWizard
  • 128,036
  • 21
  • 144
  • 167