How do airliners prevent raising the gear on the ground?
Most airliners have a protection system for this which is based on Weight-on-Wheels (WoW): sensors which detect load on the wheels (which implies that the aircraft is in contact with ground). For safety reasons this can be bypassed and there's usually a small lever in connection to the gear lever to do this. This image illustrates the 737 gear lever where you can clearly see a "lock override" which fills this functionality (red part)