1.先安装好Git
2.设置ssh密钥
ssh-keygen -t rsa -C "shell@163.com" //生成密钥 里面填的是github注册邮箱 回车三下即可
|
3.将密钥与github进行绑定,密钥在用户的.ssh文件夹里面参考:C:\Users\host\.ssh
点头像-Settings-SSH and GPG keys-New SSH key-key填入id_rsa.pub文件内容,title填一个名字–Add SSH key保存即可
4.打开git,新建一个文件夹
mkdir hello //新建文件夹 cd hello //进入这个文件夹
|
5.在hello文件夹输入自己的用户名和邮箱(为注册GITHUB账号时的用户名和邮箱)
git config --global user.name "x" //name ---github用户名 git config --global user.email "shell@163.com" // email -- github注册的邮箱 git init //通过命令git init把这个文件夹hello变成Git可管理的仓库 git add . // 通过git add.把刚才复制过来的项目全部添加到仓库上。 git commit -m "first upload" // 通过git commit -m "x"把项目提交到仓库 在github新建一个仓库 把本地仓库与github仓库关联: git remote add origin https://token_key@github.com/x/x.git //这个token_key: token_key的获取:点头像-Settings-Developer settings-Personal access tokens--Generate new token生成新的token-输入密码-Note{填写token的名字-Expiration{选择token的有效期,Select scopes中把repo勾上-点击Generate token保存即可 git push -u origin master //然后上传到master分支,-u 是因为新建的远程仓库是空的 上传成功了 git push orign mastre // 第二次上传就不需要 -u 了
|