How to uncommit and pushed directory under one particular branch?

Hi ,

I have created directory X and created two sub directories like Y and Z.

I have made Y and Z as repositories and created two separate branches for Y and Z, now added files and sub directories under Y. But unfortunately I have committed one of the directory under Y branch but it should not be under Y branch, it should be under another branch. Now I would like to undo the changes will it be possible and I would like to know the steps .