Since inchworm-like robots can exhibit excellent mobility in unstructured environments, it will be widely applied in agriculture, forestry, and high-altitude operations. Trajectory planning is an important issue for a climbing robot. This paper focuses on an inchworm-like climbing robot to plan its trajectory. The climbing process of the robot, especially the transitional gait when the robot is planned to climb over tree branches, is analyzed. Based on the gait analysis, the robot’s geometrical path is determined, and its waypoints are described by joint angles. 3-5-3 type polynomial interpolation function is adopted to fit the robot’s motion trajectory. To save the climbing time for the robot, its climbing transitional gaits for climbing over tree branches are optimized by using quantum-behaved particle swarm optimization algorithm to minimize the climbing time. Simulations are carried out to verify the developed trajectory planning, and the optimal results obtained from quantum-behaved particle swarm optimization are compared with the optimal solutions obtained by particle swarm optimization and genetic algorithm to further validate the effectiveness of the proposed method.