Let's see the context.
Acts 5:1 Now a man named Ananias, together with his wife Sapphira, also sold a piece of property. 2With his wife’s full knowledge he kept back part of the money for himself, but brought the rest and put it at the apostles’ feet.
3Then Peter said, “Ananias, how is it that Satan has so filled your heart that you have lied to the Holy Spirit and have kept for yourself some of the money you received for the land? 4 Didn’t it belong to you before it was sold? And after it was sold, wasn’t the money at your disposal? What made you think of doing such a thing? You have not lied just to human beings but to God.”
5When Ananias heard this, he fell down and died. And great fear seized all who heard what had happened. 6Then some young men came forward, wrapped up his body, and carried him out and buried him.
7About three hours later his wife came in, not knowing what had happened. 8Peter asked her, “Tell me, is this the price you and Ananias got for the land?”
“Yes,” she said, “that is the price.”
9Peter said to her, “How could you conspire to test the Spirit of the Lord? Listen! The feet of the men who buried your husband are at the door, and they will carry you out also.”
In three ways, Ananias lied to the Holy Spirit.
First Ananias knew he was lying. He knew the true amount of money but he kept part of it and pretended the reduced amount was the true amount. He lied to his own conscience which was supposed to be guarded by the Holy Spirit if indeed the Spirit dwelled in him. He let Satan filled his heart.
Second, he lied to Peter and metaphorically to the church. Peter's spirit informed him of the truth. Peter had a choice: to believe Ananias or his indwelling Spirit. Ananias lied against Peter's indwelling Spirit.
Finally, Ananias lied to God as specified in verse 4. Ananias showed contempt for God's all-knowing power thinking he could lie to God. God made an immediate example of him by striking him dead in front of the apostle, so the nascent church would fear and learn.
A similar lying occurred when Gehazi lied to Elisha about taking silver and clothing from Naaman.
2 Kings 5:25 When he went in and stood before his master, Elisha asked him, “Where have you been, Gehazi?”
“Your servant didn’t go anywhere,” Gehazi answered.
26But Elisha said to him, “Was not my spirit with you when the man got down from his chariot to meet you? Is this the time to take money or to accept clothes—or olive groves and vineyards, or flocks and herds, or male and female slaves? 27Naaman’s leprosy will cling to you and to your descendants forever.” Then Gehazi went from Elisha’s presence and his skin was leprous—it had become as white as snow.
The Spirit knows all things and teaches us all things.
John 14:16And I will ask the Father, and he will give you another advocate to help you and be with you forever— 17 the Spirit of truth. The world cannot accept him, because it neither sees him nor knows him. But you know him, for he lives with you and will be in you
But the Advocate, the Holy Spirit, whom the Father will send in my name, will teach you all things
When Ananias lied in the church, he lied to the Holy Spirit of truth who knows all things.