1:首先在官网新建仓库
会提示生成SSH keys,在电脑终端
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
cat ~/.ssh/id_rsa.pub #公钥
复制公钥内容到网站上并保存
2:打开project
在Rstudio中进入终端
git init
#添加远程仓库
git remote add origin git@gitlab.com:USERNAME/REPOSITORY.git
添加文件并提交
git add .
git commit -m "first commit"
git push -u origin master
3:此时发生报错:fetal
首先检查连接情况,成功会有successful
ssh -T git@gitlab.com
按照官网步骤
cd existing_repo
git remote add origin https://gitlab.com/****/test.git
git branch -M main
git push -uf origin main
依然报错
Git push error pre-receive hook declined
谷歌
Open your project > Settings > Repository and go to "Protected branches", find "master" branch into the list and click "Unprotect" and try again.
再回到Rstudio
git push -uf origin main
done!