dunvi
dunvi

Reputation: 53

managing multiple github accounts from one computer

I have a computer with a single account that is being shared by a number of students, and we need to be able to push to github. I've set up everything already, except getting pushes/commits to associate with individual users.

I'm a little confused by this, because it's a private repo in an organization, which I had thought would check credentials before accepting pushes, but instead it just lets anything through, apparently.

I've been googling this all night but I haven't quite been able to find an answer that seems to apply to my situation. All of the solutions/help I could find seemed to be telling people how to remove credential requirements, when that would be preferable here.

For the record:

?> git remote -v
origin https://github.com/(repo here)

so a username is not in the push url, and it's using https instead of ssh, which is what I want (I tried setting up multiple ssh keys and I don't think it's a possibility here).

The user is not set in the config files anywhere either. Originally the user.email was set to an email account attached to my personal github account and all pushes appeared under my name without requiring credentials, but I deleted that line and now everything appears under the name "shared-laptop" (user.name) with a BS email address it seems to have just made up.

I considered writing a shell script to set some of the variables every time someone starts working, but students would have to remember to run the script (they won't), and I'm not convinced it'll fix the problem.

If necessary, the current setup (committing shows up as "shared-laptop") is workable, but I think we would prefer if each person could commit under their own account. So what I'm wondering is, can I set git/github up to prompt for username and password on commits and pushes?

Upvotes: 4

Views: 1129

Answers (2)

Tarandeep Singh
Tarandeep Singh

Reputation: 1392

@dunvi Here is What you need to do.

git config --local user.name "Your Name"
git config --local user.email "Your Github Email"

Let me know if you need further help.

Upvotes: 1

iberbeu
iberbeu

Reputation: 16185

If you want to commit as a different user you can add --author to the git commit command, check:

How do you commit code as a different user?

If you want to push as a different user you can do it with https because it will ask you for the credentials, check:

How do I push to GitHub under a different username?

Upvotes: 0

Related Questions