GitHub初始化新建一个仓库
第一步:新建一个GitHub仓库
点击右边加号,点击New repository ,进入新建仓库页面,填写基本信息,点击 Create repository,此时新仓库创建成功。
第二步:确保自己的电脑和GitHub仓库地址SSH关联,GitHub配置SSH key
查看自己的电脑C盘->用户有没有.ssh文件夹,若有,说明已经有关联,可忽略此步骤,若没有,按照以下指示.
在该文件夹下右键选中Git Bash Here 打开git(若找不到这个选项,请先自行安装git)
ssh-keygen -t rsa -C "你本人的邮箱地址"
然后.ssh文件夹就会生成两个文件id_rsa和id_rsa_public,复制id_rsa_public的内容;
然后登陆自己的github,右上角图像处点击选中Settings,找到SSH and GPG keys点击,点击new SSH key,Title填写描述(随便写),把刚才复制的内容粘贴到Key,点击Add SSH key,
验证
ssh -T git@github.com
若是出现 Hi xiangshuo1992! You’ve successfully authenticated, but GitHub does not provide shell access.说明配置成功
第三步:把本地代码推送到远程地址
1、新建文件夹,把已有工程的除依赖包外全部粘贴到新文件夹下,打开git
git config --global user.name "你自己的名字"
git config --global user.email "你自己的邮箱"
git status
git add .
git commit -m "你想为本次提交代码添加的描述"
git remote add origin 仓库地址(若没有添加ssh key建议使用 https地址)
git pull origin master
git push -u origin master
若是在最后一步执行后出现如下错误,说明是在创建仓库地址时,勾选了ADD 啊README file
可以如下方案解决
//这样的错误
To https://github.com/wangjunying1/tab.git
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to 'https://github.com/wangjunying1/tab.git'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.
git pull origin master --allow-unrelated-histories
git push -u origin master
就可以推送成功了
若是想删除GitHub上面的仓库
登陆github账号,点击右边头像,点击Your repositories,打开自己的项目所在仓库,点击Settings, 最下面有Delete this repository,点击后输入自己的项目名称就删掉了