In this work, we focus on overcoming the challenge of a snake robot climbing on the outside of a bifurcated pipe. Inspired by the climbing postures of biological snakes, we propose an S-shaped rolling gait designed using curve transformations. For this gait, the snake robot’s body presenting an S-shaped curve is wrapped mainly around one side of the pipe, which leaves space for the fork of the pipe. To overcome the difficulty in constructing and clarifying the S-shaped curve, we present a method for establishing the transformation between a plane curve and a 3D curve on a cylindrical surface. Therefore, we can intuitively design the curve in 3D space, while analytically calculating the geometric properties of the curve in simple planar coordinate systems. The effectiveness of the proposed gait is verified by actual experiments. In successful configuration scenarios, the snake robot could stably climb on the pipe and efficiently cross or climb to the bifurcation while maintaining its target shape.