Indeed, it seems to work for the Taliban vs. the most powerful army on earth.
Mountainous countries remain an absolute nightmare to invade. It is no coincidence that Switzerland managed to remain neutral in the face of far larger powers and that Afghanistan is known as the Graveyard of Empires.
… in a foreign occupied country. Aside from snide remarks is anybody honestly trying to propose that civilians with guns is a deterrent for for anything the government wants to do? You may as well be throwing rocks.
The hypothesis that guns are a deterrent has little to do with the citizenry fighting against the army or the police. It is about the risk of political assassination by a rogue individual every time a politician walks outside. If the leaders start to deviate significantly from the will of the median person, that risk goes up by a lot, hence the deterrent effect. Would Kim Jong Un still be around if every person was armed? Perhaps, but it'd be quite a bit less likely.
In some cases, it probably is a deterrent. It is hard to know for sure because there is no way to A/B test a country. I think that some people probably overestimate the degree to which it is a deterrent, but I think it would certainly be wrong to say that it is not a deterrent at all. In some situations it can probably be a very effective deterrent.
granted we are in a very different place today in terms of warfare technology, history has shown that firing back is what has shaped the world we live in today.
I think you really underestimate what an entire populace geared with small arms can do if pushed too far. And thats the way it should be. The govt should be scared of crossing lines that anger the people they are supposed to represent.