All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His Slave and Messenger.
According to our view in Islamweb, making a promise to Allaah is an oath (Yameen) and a vow (Nathr), and sometimes it is only an oath. If a person abides by it as an act of devotion and obedience, then it is both an oath and a vow; like if a person says, 'I make a promise to Allaah to perform Hajj this year'; and if he abides by a promise that is not an act of obedience to Allaah, then it is an oath and not a vow, like if he says, 'I make a promise to Allaah not to speak to so and so'.
If you promise Allaah to give a certain amount in charity if you commit a certain sin, then this is like the vow of Lajaaj (anger) – which is to vow (not) to do something under a certain condition with the intent of abstaining from it or making incentive for it as clarified in Fataawa 55777 and 119549. In that case, if you commit the sin, you have the choice of either giving the said amount in charity or doing the prescribed expiation for breaking your oath (Kaffaarat Al-Yameen).
Making a promise to Allaah is not absolute Shirk, and we do not know any scholar who said this, but if we say that making a promise is a vow, then some scholars are of the view that it is disliked and some of them are of the view that it is forbidden.
Avoiding a sin out of fear of being bound by the terms of the promise is not forbidden and it is not Shirk. Ibn Al-Qayyim stated that if someone abandons a sin out of shame for people or fear of being harmed by them, then he is not punished for that. He said: “The difference between abandoning something in order to seek people's favor and to be seen of men (showing off), and abandoning something out of shyness of people or out of fear of being harmed by them or being humiliated in their eyes, is that there is no punishment for the latter.”
Therefore, abandoning the sin out of fear of being bound by the terms of the promise does not entail punishment with greater reason. However, a Muslim should avoid a sin out of fear of Allaah and to seek His Pleasure, so that he would be rewarded for abandoning the sin.
Allaah Knows best.