Cosmological simulations allow us to study the structure of the Universe at a large scale from different points of view. In particular, the cosmological magnetohydrodynamical simulation IllustrisTNG50 takes into account a wide range of physical processes that drives galaxy formation and evolution. The analysis is performed along the time from z = 4 until the present day z = 0. The disc-dominated galaxies have been divided into strongly, weakly and unbarred galaxies depending on the stellar bar properties. The evolution of the stellar bars are analysed by looking at the bar fraction, the strength and the length of the bars. Additionally, the evolution of galaxy properties such as morphology, star formation and gas content, among others, have been analysed.