Closed eduOS closed 8 years ago
It guides me to use -v for more information. And I conjecture maybe I should change git@github.com
to https://
format.
If you run the command with -v
you can see what the clone command is. It clones via ssh. Can you clone directly via ssh?
I guess a --http
option would be helpful...
In most cases I cannot given that I am not allowed to. But I can use git clone git://
or git clone https://
for all public repositories. Why should git-hub only allow the ssh protocol?
Or maybe a protocol
config variable would be more helpful.
I think most users would want to use ssh to work with the cloned repository, but on a machine where you don't have a key, you would want http for every repository.
Oh, get it. I have not set a global ssh key. But for this problem I've solved it by adding the following script to the .zshrc:
gitclone(){
git clone https://github.com/$1/$2.git
}
But I'd better add a ssh key. Thanks.
@perlpunk Sorry. I've refreshed the ssh key but failed to run it around. Could you please tell me how to set the ssh key as you said? I followed this tutorial: http://help.github.com/articles/generating-an-ssh-key. Many thanks.
You need to do three things:
If you followed the tutorial, maybe you could say what you have done exactly so far?
I thought the problem lies in the second step. Here is the setting in the ssh config file:
Host eduOS
HostName github.com
User git
IdentityFile ~/.ssh/key_for_github
Since I have more than one account on GitHub I changed the host name to my account name.
PS: I can push changes to my repo without entering password and account name.
[remote "eduos"]
url = git@eduOS:eduOS/myrepo.git
fetch = +refs/heads/*:refs/remotes/eduos/*
git push eduos master:master
I see. git-hub clones repositories with the hostname github.com. It's not possible to confiure that right now. Also for other commands which interact with the repo it expects the hostname to contain github.com.
What would work is setting the host alias manually to something like github.com-username
. For repos which are already cloned, then some git-hub commands like git hub repo
should work like expected.
But this wouldn't work for cloning. Also, git-hub only supports one user/token in the global config right now.
So to really support different github users, we'd need to
~/.git-hub-username
So for now, I'm afraid you're basically restricted to one user or a lot of manual work :-/
Or, well, a more pragmatic solution for now could be to create a small wrapper script for each user:
GIT_SSH_COMMAND="ssh -i identityfile" GIT_HUB_USER_DIR=~/.git-hub-username \
git hub "$@"
edit: use GIT_HUB_USER_DIR instead
Thanks.
@perlpunk I've tackled it by adding a default ssh key with the host name as github.com. It works well.
After I enter
git hub clone ingydotnet/git-hub
I meet a permission denied (publickey) error. It readsCould not read from remote repository, please mak esure you have the correct access rights and the repository exists.
. I suppose I may get wrong by two means: 1) the name or the owner of the repository is wrong. But I find it is not. 2) I have not set the configure file right. Here is what the .config file has:Could you please tell me where the problem lies? Thanks in advance.