git 提交代码操作-踩坑解决
一、第一次提交
克隆或者下载项目,解压
进入项目文件夹,打开cmd
# 第一次
git init
git branch -M master
git remote add origin git@gitee.com:User/project.git
# 提交代码到本地git缓存区
git add .
# 推送代码到本地git库
git commit -m “描述信息”
# 推送到云端仓库,先下拉云端的,与本地的进行合并,再推上去
git pull origin master
git push -u origin master
二、后续提交
git add .
git commit -m “描述信息”
git pull origin master
git push -u origin master
三、出现问题
1、问题一
(1)报错:
git@gitee.com: Permission denied (publickey). fatal: Could not read from remote repository.
C:\Users\荔枝\Desktop\project>git push -u origin master
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.
Please make sure you have the correct access rights
and the repository exists.
C:\Users\荔枝\Desktop\project>git pull origin master
git@gitee.com: Permission denied (publickey).
fatal: Could not read from remote repository.
(2)解决:
https://blog.csdn.net/dl962454/article/details/121944997
在步骤3出现问题
2、问题二
(1)问题:
在上述链接步骤3出现问题,公钥报错。
教程步骤: 我的问题:
(2)解决:
进入C:\Users\用户名\.ssh 文件目录,打开cmd
输入clip < id_rsa.pub ,自动复制公钥在剪贴板,重新粘贴。无错误。
3、问题三
(1)报错:
error: failed to push some refs to 'gitee.com:user/project.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.
(2)原因:
直接进行了推送。
(3)解决:
重新输入以下内容:
git branch -M master
git remote add origin git@gitee.com:User/project.git
git add .
git commit -m “描述信息”
git pull origin master
git push -u origin master
|