Plagiarism is considered a significant concern in education. Copying work from elsewhere, even from your own previous work, and presenting it as new work for an assignment is a serious disciplinary issue. At the same time, students are expected to look at, investigate, and build on the work of others. How can these two ideas be reconciled? Through honest referencing.
You are free to look at the work of others. Collaboration is the norm in computing. Git is designed for collaboration.