码云部署及提交更新文件
配置SSH公钥
使用SSH公钥可以让你在你的电脑和 Gitee 通讯的时候使用安全连接(Git的Remote要使用SSH地址)
# 生成公钥
$ ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
按照提示完成三次回车,即可生成 ssh key。
# 获取你的 public key
$ cat ~/.ssh/id_rsa.pub
将得到的公钥复制粘贴到码云官网的 设置->SSH公钥 里面,标题自定义。
# 首次使用需确认并添加主机到本机SSH可信列表
$ ssh -T git@gitee.com
在下列语句后输入 yes 并回车。
Are you sure you want to continue connecting (yes/no/[fingerprint])?
若返回下列语句则成功,就可以使用SSH协议对仓库进行操作了。
Hi xxxxx! You've successfully authenticated, but GITEE.COM does not provide shell access.
上传文件
配置环境
(xxxxx需要替换)
$ git config --global user.name "xxxxx"
$ git config --global user.email "xxxxx@xxxxx.com"
$ cd 文件夹路径
# 初始化git
$ git init
$ git remote add origin https://gitee.com/xxxxx/xxxxx.git
# 解决每次pull提交都要输账号密码的问题
$ git config --global credential.helper store
# 把远程仓库和本地同步,消除差异
$ git pull origin master --allow-unrelated-histories
更新文件
vscode更新文件
- 点开左侧边栏第三个图标sourse control,点击changes后面的加号,也可以单独点击需要更新的文件后面的加号。
- 在输入框里写此次上传的注释,也可什么都不写。然后按ctrl+回车(macOS按 command+回车)。
- 最后点击左下角的上传箭头图标(有的时候可能是朵云☁️图标),第一次上传会有弹窗提示输码云的账号密码。
终端更新文件
$ git add 【要上传的文件名】
$ git commit -m 【注释,可不写】
$ git push --set-upstream origin master