Force it.
I know it sounds dumb but it works.
When you have a negative thought, force yourself to think of something positive.
The positive thought can directly relate to that negative or be completely random.
For instance here are two examples:
At first, you think “I’m so bad at lifting weights.”
Then you realize the positive “Well, I may be bad at lifting right now but I’ve been consistently lifting five days a week for a month so soon enough I won’t be so bad.”
Another lousy thought pops into your head “I’m such an idiot!”
Immediately after force yourself to think “Well, that does suck and I might actually be an idiot but at least the weather is beautiful out today, huh, maybe I’ll go for a walk.”
Forcing positive thoughts conditions your brain to think more positively.
Eventually, the positive will outweigh the negative.
And you’ll get to a point where you can choose the positive thought over the negative instead of negative thoughts popping up out of nowhere without control all of the time.