How do I unlock a jailbroken iPhone 5?

I have an iPhone 5 running ios 6.1. I terminated my contract with AT&T and I'm switching to T-Mobile. AT&T does official unlocks but it seems like that requires a restore to factory settings. How can I unlock my iPhone so I can use it on T-Mobile without losing my jailbreak?

Thanks 🙂
Obtain imei unlock by buying it or through AT&T as you mentioned. Then use redsn0w or SAM to deactivate. Put in t-mobile sim. Wait for the "plug into iTunes to activate" message to appear. Do so.

Original thread: https://forums.imore.com/threads/how-do-i-unlock-a-jailbroken-iphone-5.256467/