Pip made sure that he kept Magwitch out of sight and found a way to sneak him out of the country by boat.
Magwitch was in danger the minute he returned to England. He was a convict expelled from the country upon pain of death for returning to England. Pip had to make sure no one saw him, so he called him Uncle Provis and had him holed up in a separate apartment near the water.
It appeared to me that I could do no better than secure him some quiet lodging hard by …. That the secret must be confided to Herbert as a matter of unavoidable necessity… (ch 40, p. 224)
He visited at night and tried to make sure no one was following. Then he and Herbert arranged to escape by boat, until they got caught when Compeyson betrayed them.