Judge Greg Hollister-Jones explained, on December 2, 2017, Phillips was drinking with some gang members when two senior patched member of the Mongrel Mob told a group to exhume Lines' coffin.
"You were told you had a choice but refusing might result in you being assaulted so really you had few options."
Hollister-Jones said Phillips was part of a group which drove to the urupa and started digging.
They were disturbed by police and fled before they reached the coffin.
The victim impact statement written by Lines' sister said the family was disgusted by what had happened.
"They found it highly disrespectful and emphasised this urupa had seven generations buried there," the judge said.
"What happened there was disturbing to this whānau and the ancestors laid to rest in that urupa."
Phillips' lawyer Andrew Schulze said there had been restorative justice meeting between his client and the family.
Lines' family was in court for the sentencing and Schulze said that was a testament to Phillips.
Hollister-Jones accepted the restorative justice process was meaningful.
"You have now got a greater awareness of tikanga and come to the realisation you desecrated that grave and disrespected it and the whānau and ancestors buried there. You're remorseful for the pain your actions have caused," he said.
"You were put under pressure from senior gang members, however you are 25 and did have a choice though it was restrictive. What's most significant is the breach of tikanga.
"Fronting up is very important and you've done that, but on behalf of the community the court must hold you accountable and make it clear this was offensive and unacceptable."