Git提交代码操作-踩坑解决

git 提交代码操作-踩坑解决

一、第一次提交

克隆或者下载项目,解压

进入项目文件夹,打开cmd

# 第一次
git init
git branch -M master
git remote add origin [email protected]:User/project.git

# 提交代码到本地git缓存区
git add .
# 推送代码到本地git库
git commit -m “描述信息”
# 推送到云端仓库,先下拉云端的,与本地的进行合并,再推上去
git pull origin master
git push -u origin master 

二、后续提交

# 后续代码提交
# 提交代码到本地git缓存区
git add .
# 推送代码到本地git库
git commit -m “描述信息”
# 推送到云端仓库,先下拉云端的,与本地的进行合并,再推上去
git pull origin master
git push -u origin master 

三、出现问题

1、问题一

(1)报错:

[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.

C:\Users\荔枝\Desktop\project>git push -u origin master
[email protected]: 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
[email protected]: Permission denied (publickey).
fatal: Could not read from remote repository.
(2)解决:

https://blog.csdn.net/dl962454/article/details/121944997

在步骤3出现问题

2、问题二

(1)问题:

在上述链接步骤3出现问题,公钥报错。

教程步骤:
Git提交代码操作-踩坑解决_第1张图片
我的问题:
Git提交代码操作-踩坑解决_第2张图片

(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.

Git提交代码操作-踩坑解决_第3张图片

(2)原因:

直接进行了推送。

(3)解决:

重新输入以下内容:

git branch -M master
git remote add origin [email protected]:User/project.git
git add .
git commit -m “描述信息”
git pull origin master
git push -u origin master 

你可能感兴趣的:(Git,git,github)