在GitHub上建立Git仓库
登录后点击“new repository”按钮新建仓库

点击“creat repository”按钮创建仓库
一般选择Public,如果是私有仓库选择Private

配置git config
配置用户名和用户邮件,命令行输入下面命令:
git config --global user.name “YourName”
git config --global user.email “YouEmailAddress”
若省略了“--global”,则只配置当前仓库用户信息
生成SSH密钥并添加到Git
打开终端,输入下面的命令:
ssh-keygen -C “YouEmailAddress” -t rsa
然后直接按回车使用默认路径保存密钥文件到当前用户文件夹中,此时如果提示如下
.ssh/id_rsa already exists.
Overwrite (y/n)? y
输入no,密钥文件为(.ssh),接着设置密码和再次输入密码
查看sshkey:
vim ~/.ssh/id_rsa.pub
添加SSH密钥到GitHub
到GitHub中点击右上角的account->settings->SSH and GPG keys,然后选择左边栏中的SSH Keys添加SHH Key粘贴刚才复制的内容到Key文本框中,title随意
注意ssh key要全部拷贝,包括前缀、后缀,大概如下样子
ssh-rsa ........... yourEmail
填写完毕后点击 Add SSH key按钮

创建本地仓库
命令行cd到本地项目根目录
cd yourPath
再输入:
git init
提交本地项目
命令行输入下面命令:
git add .
提交输入下面命令:
git commit -m “msg”
添加源到Git
git remote add origin 仓库地址
push源到Git
git push -u origin master
网友评论