这可能不是重复; 我已经阅读了StackOverflow上的许多类似问题,但没有读过这个问题.
我试图在Ubuntu Linux上使用多个git帐户,每当我尝试从第二个帐户推送时,它认为我仍在使用第一个帐户的用户名.
$ git push -u origin master
ERROR: Permission to <act2>/<repo>.git denied to <act1>.
Run Code Online (Sandbox Code Playgroud)
我首先尝试了多个SSH密钥方法.当我收到上述错误后,我在本地计算机上创建了一个全新的用户,以该用户身份登录,重新创建了本地仓库(它是第一次推送)并再次尝试.同样的错误.我的本地.config显示用户,我的〜/ .gitconfig也是如此.
有任何想法吗?
我这样做:ssh @localhost然后是ssh -vvv -T git@github.com
我得到了这个有趣的输出.它似乎在我的帐户中找到了一个密钥.但不知何故,它在我的帐户中使用了一个密钥,实际上应该无法访问.
debug1: Host 'github.com' is known and matches the RSA host key.
debug1: Found key in /home//.ssh/known_hosts:1
debug2: bits set: 513/1024
debug1: ssh_rsa_verify: signature correct
debug2: kex_derive_keys
debug2: set_newkeys: mode 1
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug3: Wrote 16 bytes for a total of 1015
debug2: set_newkeys: mode 0
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_REQUEST …Run Code Online (Sandbox Code Playgroud) 我有一个使用的库函数**kw,但我想传递一个类字典类,以便我可以覆盖它__getitem__来跟踪它对字典中数据的访问.例如,在下面的代码中调用libfn不会打印Accessed但libfn2会打印.
class Dtracker(dict):
def __init__(self):
dict.__init__(self)
def __getitem__(self,item):
print "Accessed %s" % str(item)
return dict.__getitem__(self, item)
def libfn(**kw):
a = kw["foo"]
print "a is %s" % a
return a
def libfn2(kw):
a = kw["foo"]
print "a is %s" % a
return a
d = Dtracker()
d["foo"] = "bar"
libfn(**d)
libfn2(d)
Run Code Online (Sandbox Code Playgroud)