4

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?

3
  • Why not make a separate login on the computer for each student? I mean login to the OS, not just GitHub. Commented Mar 4, 2013 at 11:37
  • I don't think I have permissions to do that on this computer, or we would have done that ages ago. Commented Mar 4, 2013 at 18:58
  • stackoverflow.com/a/31351376/1922144 Commented Jul 12, 2015 at 3:00

2 Answers 2

1

@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.

Sign up to request clarification or add additional context in comments.

Comments

0

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?

1 Comment

As I said in the original post, I have the remote set to https and it's not asking for credentials.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.