Here’s how to reset passcode, pattern, or your password on an Android smartphone with an unlocked bootloader. Now, this will ONLY WORK if you have access to TWRP or you can flash TWRP recovery using fastboot.
This is really good for those of you who forgot your passcode on your older TWRP backups or your TWRP backups messed up your passcode(which can happen when using early beta TWRP).
Step 1. Boot into TWRP recovery.
Step 2. Go to Advanced->File Manager.
Step 3. Browse to /data/system folder.
Step 4. Erase any files beginning with “locksettings”.
Step 5. Reboot and you should be able to unlock phone without any passcode.