If you are using those tow accounts with different ssh keys (as described in "How do programs like gitolite work?"), the way you switch is by using an ssh url which instructs ssh to look for noah's key (instead of admin's key).
For that, you need an ssh config file (in your HOME/.ssh/config
), as I detailed in "How to use specified key when working with github via portablegit?":
#admin account
Host gitolite-admin
HostName yourGitoliteServer
User git
IdentityFile ~/.ssh/id_rsa_admin
#noah account
Host gitolite-noah
HostName yourGitoliteServer
User git
IdentityFile ~/.ssh/id_rsa_noah
To clone your repo made for noah, you would use an url which reference the right entry in the ssh config file.
git clone gitolite-noah:yourRepo.git
By using that url, you are setting a remote named origin
: you can see it with git remote -v
.
That means any command using that remote name (like git pull origin or git push origin) will use that ssh url, which explicitly refers to a specific private ssh key, which in turn identifies you to Gitolite as noah
.
The most effective way to debug ssh is by checking how the sshd listen to the query on the server.
Since it is a debian (as per out discussion):
/usr/sbin/sshd -d -D -p 222
on the server,
ssh -p 222 -Tv git-noah
on the client
(note the trick of using a dedicated port, that way, no need to stop the actual sshd: it is a one-time session on a special port for debug purpose only)
We quickly saw a
Could not open authorized keys '/home/git/.ssh/authorized_keys': Permission denied
Which is consistent with:
root@server:/# ls -lato ~git/
drw------- 2 git 4096 Apr 19 14:57 .ssh
A chmod 700 ~git/.ssh
fixed the situation.
By default, git is using a system-wide configuration file or the one stored at top of your home directory.
But you can also set a file .git/config
inside each repository, either by editing manually or using git config
. Inside, you may specify the following sections :
[user]
name = Your name
email = [email protected]
…
[credential "<your_project_hoster_url>"]
username = <username to log in with>
You can check git config in general or git credentials in particular for more information about it.
Best Answer
Make a repository clone for each developer on mac, and set user.name and user.email config variable for each clone (project level property). So, in this case each developer have to use own project (just different directories).
To set project level property execute (current directory should be the root of the project):
UPDATE Also if the only reason you are using the same login for different developers is disk space, you can create one clone in /Users/Shared/, configure user.name and user.email variables in $HOME/.gitconfig and voila!