I got the gift of discerning of spirits from God before I knew what gifts were. He used it to help me understand the spirits that were in me from my past, and ones that were attacking me spiritually and through other people too, to discern between them and the Holy Spirit. So for me, it came while Jesus was setting me free, and then He has increased it more and more as He has been using me to help others. The gift is also used to discern between true and false prophets. We look at the fruit from a Biblical perspective and see what words the spirits are giving to the prophets, and look at how the spirits are manifesting physically. Some false prophets also speak from the flesh, and in that case, I see that it's a human spirit, nothing supernatural involved. I see spirits in their eyes, hear them in their voices, and in the body movement.
God also speaks to my spirit about what is going on in the person. I can discern what kind of spirit it is, whether a divination spirit, a kundalini spirit, a lying spirit, spirit of satan etc. All of the discerning of spirits comes from God, as He reveals to me what he is seeing. He reveals to me if the light I'm seeing is Light from God or false light from deceitful spirit. Matthew 6:22-24, 2 Corinthians 11:14-15
Just because something feels good and sounds good, doesn't mean that it is good. Discerning between what is good and evil is also a part of the gift, and it is what it is meant to be used for. I have also learnt to tell the difference between the presence a real Holy Angel and a false angel of light. This gift is extremely useful, because the church is full of false angel experiences and deceitful spirit in general too. I can also tell if a gift is genuine or counterfeit, and if signs and wonders are from God or from the devil.
When someone is taught another gospel and another "jesus", they also receive a different spirit than the real Holy Spirit. 2 Corinthians 11:4. It is not always the spirit of the anti-christ, but most often it is. This is where God has been using my gift mostly, to root out spiritual deception from someone's life. In the future, He will use me in churches as well.
There is a counterfeit gift of discerning of spirits too, that is a divination spirit. It isn't based on Truth but only on spiritual experiences. Since those who have that counterfeit gift is seeing the spirits from the eyes of that spirit, they will see false light as if it's from God and be deceived. They will see good as evil, and evil as good, they cannot tell if the light in a person is real Light or darkness. Even when it's chaotic and confusing, they still see it as good. So it is extremely important that we base our discerning not only on what we perceive spiritually, but on Scripture and on sound doctrine and a sound mind given by the Holy Spirit. We have to know Him and keep our eyes on Him, and He will reveal to us what is true or not.

I hope this helps. My gift is genuine and of God, because it gives Glory to God and exposes the works of the devil every time. It's awesome!
