A warm-up is the short stretch of easy work you do before the work that counts. For lifting, it does three plain things: it raises your body temperature and heart rate a little, it lets you rehearse the movement with a light load, and it helps you feel whether today is a heavy day or a sluggish one before the bar is heavy.
That is about all it needs to do. It does not need to be long, and it should never tire you out. If you finish your warm-up already puffing, you have started your workout early and spent energy you wanted for the real sets.
Think of it as general first, then specific.
General (2 to 3 minutes). Anything that gets you moving and slightly warmer: brisk walking, an easy bike, a rower at a conversational pace, or a few rounds of bodyweight squats, arm circles and hip hinges. You should feel a little warmer, not tired.
Specific (3 to 5 minutes). Do the first exercise of your session, but lighter, and build up to your working weight in a few steps. These are called ramp-up sets. They are the part most beginners skip, and the part that matters most: your first heavy set stops being the first time you have done the movement that day.
Only the first exercise of each muscle group needs a full ramp-up. If you squat first, the lunges that follow need maybe one light set.
Enter the weight you plan to use for your first working set, and the weight of the empty bar (or whatever your lightest start is). The ladder below shows a sensible build-up. The sets get heavier while the reps drop, so you rehearse without tiring.
Go through the sets in order and treat every warm-up rep as practice: same stance, same grip, same depth, same control as your working sets. Stop each warm-up set well before it feels hard. If the 85% set already feels heavy, that is useful information: today might call for slightly lighter working weights, and that is fine.
The same idea scales down. For a bodyweight session, the ramp-up is an easier version of the movement: wall or incline push-ups before floor push-ups, a shallow squat to a box before a deeper one.
Long static stretches, where you hold one position for a minute or more, right before heavy lifting may slightly reduce how much force a muscle can produce for a short time. The effect is small for short holds, but it makes them a poor use of warm-up time. Save long stretches for the end of the session or a separate day, and use movement-based warm-up (the ladder above, plus a few easy dynamic moves such as leg swings or hip hinges) before you lift.
Warm-ups are also not a guarantee against injury, and nobody should promise you that. What they do is make the first heavy set feel more familiar and controlled.
If you have an injury, ongoing pain, or a heart or other medical condition, check with a doctor or physiotherapist about what warm-up and loads suit you. Sharp pain during a warm-up set is a reason to stop, not to push through. The ladder is a general starting point for healthy adults, not a prescription.