Vscode中配置gitEE过程及踩坑
一. Git仓库为空时(新建Git仓库时)
1.新建仓库
注意别新建README.md文件,否则会很麻烦
2.创建后的空仓库
3.新建空文件夹用于存放远程仓库
4.在文件夹下的终端依序执行以下命令
//全局设置
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱@qq.com"
记住账号密码
git config --global credential.helper store
//创建git仓库
//创建本地仓库的文件夹
mkdir 自定义本地仓库文件夹
cd 本地仓库文件夹
git init
//新建README.md文件
touch README.md
git add README.md
git commit -m "test commit"
//生成gitEE仓库对应的本地连接
git remote add 自定义本地连接名 你的gitEE仓库链接
//push
git push -u 本地连接名 gitEE仓库分支名
5.连接成功
二. Git仓库不为空时
1.从第3步开始
//全局设置
git config --global user.name "你的用户名"
git config --global user.email "你的邮箱@qq.com"
//记住账号密码
git config --global credential.helper store
//创建git仓库
//创建远程仓库的文件夹
mkdir 自定义本地仓库文件夹
cd 本地仓库文件夹
git init
//新建README.md文件
touch README.md
git add README.md
git commit -m "test commit"
//生成git仓库对应的远程仓库
git remote add 自定义本地连接名 你的gitEE仓库链接
2.先从已存在的仓库将文件pull到本地
git pull 本地连接名 gitEE仓库分支名 --allow-unrelated-histories
//做任意修改
//***********
//push
git push -u 本地连接名 gitEE仓库分支名
3.再次连接成功
踩的坑----
1.refusing to merge unrelated histories
git默认不允许两个无关联的分支合并,解决方法:pull或push时语法后添加
--allow-unrelated-histories
2.Updates were rejected because the remote contains work that you do
连接已存在内容的仓库时,不能直接push,要先将内容pull至本地,再push回去
git pull 本地连接 gitEE分支 --allow-unrelated-histories