First, who is giving you a gift?
If it is someone you do not like and you know there are alternative motives, politely refuse. If they insist, refuse again. No matter what the gift is, refuse.
If it is a gift of someone trying to make amends, think if you are being bribed with the gift or if they are sincerely sorry and giving out of care for you. If you are the disagreement starter, realize how desperate this person is to be in an alright place with you - but if the gift is something personal, as a token of things being alright and that you're sorry, give them a gift. If the gift was something they prized, return it but with a pleasant alteration or a "bonus" or with something you prize.
If someone you don't know gives you a gift, think about their motives. If they are trying to buy your affection and a favor before you know them well or have even been introduced, you may accept but think of it as a bribe. Think of what it means, not of what it is, not if it is something you want. It is a complicated situation and is up to you and your judgment.
When a casual friend gives a gift, it probably won't be anything you might treasure for your whole life, so a thank you and a smile will do.
If a closer friend tries to give you a gift, you will begin to find the closer and more dear the giver the harder it is to receive. This is because it is easy to feel guiltless taking something from a stranger or someone you do not know well, but when someone who is closer to your heart gives from their heart to you, the weight of it is a hefty weight indeed. You may even feel extreme guilt, shame, or in literal debt to the person. It steals some fun from receiving, but don't you remember when you were younger and it was your birthday and it didn't matter who gave the gift, you just had the pure joy of getting. Don't feel guilty about that, instead, be thankful and let a little of that leak into being loved by someone dear to you.
When the someone you love gives you a gift it is hard to know how to react. You want to show them how much it means, how amazing it is to you that they are 'giving' to you.
You may act undeserving, refuse the gift because it was 'too much', or may quickly give them a gift in return.
The best way to receive a gift is to show joy, that is the best way. It rewards the giver, and lets you enjoy your gift, lets you feel pleasure and appreciation that is guiltless. Don't act false, but think about the thought that went into your gift.
To receive what was not 'bought' for yourself is the most humble of things.
To receive something you didn't earn, could not earn, is humbling but it should also bring a happiness of getting something.
To say you don't deserve or have not earned is irrelevant, but it will hurt the giver, because the fact they are giving makes you deserving.
The receiver is always deserving in the heart of one who loves them. Enjoy your gift. You are somebody's favorite person.