美文网首页
换设备后Github 与Gitee远程仓库连接克隆及本地推送远程

换设备后Github 与Gitee远程仓库连接克隆及本地推送远程

作者: wangjunmech | 来源:发表于2018-08-21 10:01 被阅读0次

    #1.先要生成SSH加密key,在Git Bash命令中输入命令后生成本地密匙文件,参考如下:

    github(设置->SSH)

    https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/

    gitee(Settings->SSH and GPG keys)

    http://git.mydoc.io/?t=154712

    默认生成的密匙目录:C:\Users\用户名\.ssh\

    #2.添加SSH key,把本地密匙内容提交到服务器,在设置中添加SSH,github(New SSH key), gitee(添加公钥)

    github

    添加id_rsa中的内容

    gitee添加id_rsa.pub中的内容

    #3.配置本地账户名及邮箱

    github

    git config --global user.name "your name"

    git config --global user.email "your_email@youremail.com"

    gitee

    git config user.name "your name"

    git config user.email "your_email@youremail.com"

    #4. 检查是否成功配置密匙,在gitBash命令行输入如下命令查看结果

    ssh -T git@github.com (结果:Hi

    用户名! You've successfully authenticated, but GitHub does not provide shell access.

    )

    ssh -T git@gitee.com(结果:Welcome to Gitee.com,用户名!)

    #5. 配置成功即可使用 git clone 命令

    本地项目推送到github远程仓库

    1.在本地项目文件夹中运行git init

    2.git status, git add.,git commit -m '说明'

    3.远程新建仓库,名称与本地目录名相同,获得SSH路径git@github.com:用户名/仓库名.git

    4.添加远程仓库。命令 git remote addooo git@github.com:用户名/仓库名.git

    如果显示ooo已存在,可以使用与之对应的移除命令:$ git remote rmooo,然后再添加远程仓库。

    git config --list 命令查看已经设置的配置,如果要删除配置,使用

    5.命令 git push -uooo master

    说明:远程库的标示Git默认的叫法origin,上面4.5.命令下把它改成ooo,必须要一致

    相关文章

      网友评论

          本文标题:换设备后Github 与Gitee远程仓库连接克隆及本地推送远程

          本文链接:https://www.haomeiwen.com/subject/dqddiftx.html