I’m currently using GitHub classroom for deploying lab exercises. Students use the
git commands directly from the command line to push their code.
Interestingly, I’ve noticed that some commits showed a different username than that of the student. For example, Student y’s repository shows commits by Student x. However, it was Student y that actually commited/pushed the code. I was there when they did it so it’s not like they cheated. The repos are also private so no one else should have access. Has anyone experienced the same thing?
I think it has something to do with the machines they are using. Currently, each student logs in to a computer then runs a Linux virtual machine where they develop code and make pushes to GitHub. When students moved to a different machine and pushed their code (using their own GitHub username and password) it would show a different student’s username.
Suggestions on how to resolve the issue so that the right student’s username appears on the commits are much appreciated.
I’ve had this when a student has more then one account. Its easier to have happen on the command line because its harder to see who you are logged in as. I do set their repositories as private.
What puzzles me is how it can happen technically. Since their repositories are private, I’d expect github to reject a commit from other accounts. My working theory is that they are logged in somewhere else with the correct credentials (say in a browser) and it is partially using those other credentials. This would match your experience of picking up other students info when they change machines.
Good Luck. I’ve no answers but at least I can confirm that similar things happen to other people.
Is the username correct when you do a
git log before pushing?
If it is not then then problem is that you are committing under the wrong username. Git stores the default username and email for all commits in the
~/.gitconfig (also editable via
Note that it can be that one user commits but a different user pushes to github. In these cases github will actually show two little user icons instead of one.
This is an issue I often face with my students, especially in a shared lab environment.
The issue is that GitHub uses the Email Address that is set in git to link to the username and NOT their login credentials. If the student set their email address globally, git might use it for the commit, even if its for a different student.
More info: https://help.github.com/en/articles/why-are-my-commits-linked-to-the-wrong-user
I just have my students remove the global configs when they’re done.
Thanks for all your insights @phannan @josemvidal and @FransBlauw!
It’s inconvenient for students to have to change the config or remove it every time. It’s another thing they have to remember on top of the actual lessons they are learning in class. It would have been easier if GitHub just used the account that pushed the code.
Anyway, perhaps GitHub focuses on an entirely different use case as a classroom setting. Still something for them to consider.