参考:
https://blog.csdn.net/qq_39400546/article/details/100150320
https://blog.csdn.net/aiming66/article/details/81051428
https://blog.csdn.net/qq_27597629/article/details/87718844
使用git将代码提交到码云过程记录
一、下载安装git
打开https://git-scm.com/
下载并安装git
二、创建本地git库
进入项目下的目录,右键Git Bash Here
git初始化
git init
设置用户名和邮箱
git config --global user.name "xxx"
git config --global user.email "xxx@163.com"
将文件添加到暂存区
git add .
将文件提交到本地仓库
git commit -m "first"
三、提交代码到码云
注册码云账号https://gitee.com/
创建仓库
创建公钥
ssh-keygen -t rsa -C "xxx@163.com"
一直回车,我这里显示秘钥生成在C:\Users\Administrator.ssh里
打开id_rsa.pub复制秘钥
打开码云,右上角头像点设置
选择左边的“SSH公钥”,添加一个新公钥,标题随便输入,将复制出来的公钥填进去
点击刚刚创建的项目,复制ssh地址
在git添加远程仓库
git remote add origin 远程仓库地址
从远程获取内容,然后将其合并到当前分支中
git pull origin master
这时候出现fatal: refusing to merge unrelated histories的问题
两个分支是两个不同的版本,具有不同的提交历史,允许不相关历史提,进行强行合并
git pull origin master --allow-unrelated-histories
第一次提交要
git push -u origin master
刷新码云就可以看到提交的文件了~~