1

I have a Git repository with multiple users. When they push, is it possible for me to read arguments from the client command line? For example, username and password?

I tried read in my bash script, but it does not work. I cannot access STDIN.

How can I read something from the client command line in a Git hook (update)?

David Cain
  • 16,484
  • 14
  • 65
  • 75
王振威
  • 35
  • 1
  • 3

1 Answers1

1

No. Git doesn't do any authentication. (See "Distributed Version Control Systems and the Enterprise - a Good mix?")

You can get the user id from the https session or the ssh one (if the ~git/.ssh/authorized_keys file contains that information): that is what gitolite does: see "How do programs like gitolite work?".

You won't certainly get the password. Ever. (And that has nothing to do with git or gitolite).

And gitolite will in turn call git itself (if it authorizes the clone/push/pull command), but git, again, will be blissfully unaware of the user's id requesting said clone/pull/push: it will simply execute it.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • but how github do this?why github allow user do a pushing with http/https ,what should i do is just input my email and password. – 王振威 Jan 04 '13 at 07:35
  • @王振威 GitHub has an Apache which listen to remote request, and will validate user/passwords against their own internal user database. You can store your login/password locally (http://stackoverflow.com/questions/5377703/syncing-with-github/5378094#5378094), but they will be used by their GitHub font-end (like an Apache or ssh), not by git or any hook on github side. – VonC Jan 04 '13 at 08:01