Method to control a hybrid powertrain, comprising a combustion engine; a gearbox with an input shaft and an output shaft, which combustion engine is connected to the input shaft; a first planetary gear, which is connected to the input shaft; a second planetary gear, connected to the first planetary gear; a first electrical machine, connected to the first planetary gear; a second electrical machine, connected to the second planetary gear; at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft; and at least one gear pair (G2, 66, 78) connected with the second planetary gear and the output shaft, which gear pairs (G1, 60, 72, G2, 66, 78) are connected to the output shaft via a countershaft, characterised by the steps: a) to engage gears corresponding to the at least one gear pair (G1, 60, 72) connected with the first planetary gear in the gearbox; b) to connect two rotatable components (22, 26, 50) in the first planetary gear with a first coupling device; e) to activate the second electrical machine so that the second electrical machine generates a propulsion torque on the output shaft via the at least one gear pair (G2, 66, 78) connected with the second planetary gear and the output shaft; f) to disconnect the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft from the countershaft, which gear pair was connected in step a), by controlling the first electrical machine and a combustion engine connected with the first planetary gear in such a way that a substantially zero torque state is achieved between the at least one gear pair (G1, 60, 72), connected with countershaft which gear pair is connected with the first planetary gear and the output shaft, and the countershaft; g) to connect the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected in step a), with the countershaft by controlling the combustion engine in such a way that a synchronous rotational speed is achieved between the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected in step a), and the countershaft; and h) to activate the combustion engine and/or the first electrical machine, so that the combustion engine and/or the first electrical machine generates a propulsion torque on the output shaft via the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected to the countershaft in step a). a) to engage gears corresponding to the at least one gear pair (G1, 60, 72) connected with the first planetary gear in the gearbox; b) to connect two rotatable components (22, 26, 50) in the first planetary gear with a first coupling device; e) to activate the second electrical machine so that the second electrical machine generates a propulsion torque on the output shaft via the at least one gear pair (G2, 66, 78) connected with the second planetary gear and the output shaft; f) to disconnect the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft from the countershaft, which gear pair was connected in step a), by controlling the first electrical machine and a combustion engine connected with the first planetary gear in such a way that a substantially zero torque state is achieved between the at least one gear pair (G1, 60, 72), connected with countershaft which gear pair is connected with the first planetary gear and the output shaft, and the countershaft; g) to connect the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected in step a), with the countershaft by controlling the combustion engine in such a way that a synchronous rotational speed is achieved between the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected in step a), and the countershaft; and h) to activate the combustion engine and/or the first electrical machine, so that the combustion engine and/or the first electrical machine generates a propulsion torque on the output shaft via the at least one gear pair (G1, 60, 72) connected with the first planetary gear and the output shaft, which gear pair was not connected to the countershaft in step a).