Stick to one’s guns is a very old saying or an idiomatic expression which means to stay firm or maintain one’s position even in the most unfavorable circumstances; to stand up for one’s rights and beliefs no matter what happens.
The soldiers stuck to their guns and refused to surrender.
She stuck to her guns and continued her fight against injustice for many years.
Stick to your guns is the informal and more commonly used version. It means to refuse to change your beliefs or actions.
My parents want me to study science but I’m sticking to my guns and opting for commerce.
The idiom stick to your/one’s guns seems to have its origin in the military set up. This was a command given to the soldiers operating the guns on military boats. They had to stay at their positions even when the boat was being attacked by enemies and had orders to continue shooting at the enemy although it put them in great danger. The guns were to be defended till the end, hence “stick to your guns”.