您的位置:首页 > 编程语言

push代码到Github免输入用户名和密码

2013-12-17 21:15 274 查看
在Github上建立了项目,在每次push代码的时候,都要输入用户名和密码,很麻烦,原因是使用了https方式 push,
在termail里输入:

git remote -v


可以看到形如一下的返回结果

origin https://github.com/twlkyao/demo.git (fetch)
origin https://github.com/twlkyao/demo.git (push)
1.可以先删除https方式的,然后添加ssh方式的。

git remote rm origin
git remote add origin git@github.com:twlkyao/demo.git
git push origin


2.也可以通过修改项目目录下的.git/config文件完成。
[remote "origin"]
        url = https://github.com/twlkyao/demo.git         fetch = +refs/heads/*:refs/remotes/origin/*
将url处改为ssh地址。
[remote "origin"]
        url = git@github.com/twlkyao/demo.git
        fetch = +refs/heads/*:refs/remotes/origin/*



3.直接设置新的url

git remote set-url origin git@github.com:twlkyao/demo.git
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: