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

来源:互联网 发布:js html格式化工具 编辑:程序博客网 时间:2024/05/05 16:15

    在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 origingit remote add origin git@github.com:twlkyao/demo.gitgit 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


0 0
原创粉丝点击