How to avoid plagiarism if I am learning from other's code?
You could add a (conspicuous) comment to the code explaining how you wrote the code and that you used the tutorial from GitHub. If you credit your sources and explain how the code come about, it can never be plagiarism.

You could also ask your lecturers in advance whether they think what you did is acceptable. When it comes to programming assignments, there is some variance from lecturer to lecturer in what they consider acceptable.