[2018-02-22] Git之远程仓库

前置条件

使用Git远程仓库;

本地Git仓库和GitHub仓库之间的传输是通过SSH加密的;

步骤

step1:创建SSH Key

在第一步指定的HOME目录下建立.ssh(注意前面有个点)文件夹,打开git bash,切换到.ssh目录中(git bash中的命令同linux下命令),在命令行下生成ssh证书:

$ ssh-keygen -t rsa -f filename

$ ssh-keygen -t rsa -C "youremail@example.com"

step2:设置github账户

Copy the SSH key to your clipboard.

In the upper-right corner of any page, click your profile photo, then click Settings.

In the user settings sidebar, click SSH and GPG keys.

Click New SSH key or Add SSH key.

In the "Title" field, add a descriptive label for the new key. For example, if you're using a personal Mac, you might call this key "Personal MacBook Air".

Paste your key into the "Key" field.

Click Add SSH key.

step3:创建并关联远程库

Create a new repository

输入Repository name

Create repository

本地命令行:$ git remote add origin [url],远程库的名字就是origin

step4:推送至远程库

$ git push [-u] origin master

把本地库的内容推送到远程,用git push命令,实际上是把当前分支master推送到远程。

首次推送添加-u参数,一来推送本地分支至远程,二来关联本地和远程分支,以后的推送或者拉取时就可以简化命令。

SSH警告

known hosts信任列表

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容