2

私は、https アクセスのみを許可するように git リポジトリ (gitolite) が構成されているプロジェクトに取り組んでいます。さらに悪いことに、私が認証するために彼らが作成したユーザー名はひどいものです。私の .git/config では、私のコミットが正しく私に関連付けられるように、user.name を私の本名に設定しています。ただし、プッシュまたはプルするたびに、恐ろしい認証ユーザー名を覚えて正しく入力する必要があります (それでも非表示です!)。ローカル git リポジトリの構成で認証ユーザー ID を設定したいと考えています。

http://git-scm.com/docs/git-configおよびhttp://git-scm.com/docs/gitcredentials.htmlに従って、試しました

git config credential.username <bletcherous-name>

git config credential.https://git-server.myco.com.username <bletcherous-name>

しかし、これらは効果がありませんでした。接続するたびに、ユーザー名の入力を求められました。

最終的に、次のことができることがわかりました。しかし、以下はハックであり、上記はうまくいくはずだったようです。私が間違っていることは何ですか?

git remote rm origin
git remote add origin https://bletcherous-name@git-server.myco.com/git/my-repo.git
4

1 に答える 1

1

要約すれば:

git config --local credential.https://git-server.myco.com.username bletcherous-name

これと他の同様のことが Git 構成ファイルに対して行うことを示すシェル トランスクリプトを次に示します。したがって、(私が好むように) 構成ファイルを直接編集することができます。

localuser@localhost:~$ mkdir foo
localuser@localhost:~$ cd foo
localuser@localhost:~/foo$ git init
Initialized empty Git repository in /home/localuser/foo/.git/
localuser@localhost:~/foo$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
localuser@localhost:~/foo$ git remote add origin https://bletcherous-name@git-server.myco.com/git/my-repo.git
localuser@localhost:~/foo$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://bletcherous-name@git-server.myco.com/git/my-repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
localuser@localhost:~/foo$ git remote rm origin
localuser@localhost:~/foo$ git remote add origin https://git-server.myco.com/git/my-repo.git
localuser@localhost:~/foo$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://git-server.myco.com/git/my-repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
localuser@localhost:~/foo$ git config --local credential.https://git-server.myco.com.username bletcherous-name
localuser@localhost:~/foo$ cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[remote "origin"]
url = https://git-server.myco.com/git/my-repo.git
fetch = +refs/heads/*:refs/remotes/origin/*
[credential "https://git-server.myco.com"]
username = bletcherous-name
localuser@localhost:~/foo$
于 2013-09-26T05:58:44.280 に答える