Unless you have hacked at the data in the .git
directory, it is unlikely that you've lost anything. You may have a terrible mess to clean up, and it may take a lot of working out what you did and where it is, but you probably haven't lost anything.
That's the good news.
The bad news is that it is going to be fiendishly difficult for anyone to help you much.
You are likely to need to identify all the branches, and trace backwards the commits on each. You'll need to decide whether all those 'git commit -a
' operations were a good idea. It sounds unlikely - so you may need to do your merges properly, working from the next to last commit on each branch.
You also need to decide what you were really trying to do.
It sounds like you wanted to merge some number of branches - call them BranchA, BranchB, and BranchC - onto the main branch, master. But it is not clear that is what you tried.
Given that things are something of a mess, I recommend creating another branch which we can call 'Fixup'. Create this from the head of the master branch. Then, merge the appropriate version of each of BranchA, BranchB and BranchC into the Fixup branch. At each stage, check that the code actually works correctly - passing its test suite, etc. Check in each merge separately on the Fixup branch.
When you are satisfied that the Fixup branch is correct, switch back to the master branch and merge the Fixup branch to master.
Charles Bailey makes the very sensible suggestion (in a comment to the question): before you do anything else, make a backup copy of what you've got, exactly as it currently is. Only then proceed with any cleanup operations. And his suggestion to get interactive help is also sensible.