git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决

简介: git修改提交路径以及强制提交——异常:error: remote origin already exists.与异常:error: failed to push some refs to的解决



 

异常1:error: remote origin already exists.

这里说的是你当前上传的内容在远端已经存在了,我们需要查看一下我们当前的提交路径,删掉后重新配置一下。

步骤1、查看

git remote -v

步骤2、删除

git remote rm origin

执行完是没有任何返回的。

步骤3、更换路径

git remote add origin 目标git地址

更换完成没有任何的显示。

异常2:error: failed to push some refs to

可以看到使用push提交的时候报错了,问题是有冲突,我的解决办法是线下解决,解决完毕后直接-f强行覆盖即可。

解决方案1:

强行覆盖命令:

git push -f origin master

提交完毕:

这就解决了。

解决方案2:

拉取代码以后再次上传

git pull --rebase origin master

拉下来后就能自行解决冲突了,解决完就可以干干净净的上传了。

git push origin master

我这里一般确定文件内容后一般也就直接强行覆盖了,还是覆盖方便,但是偶尔也会出错,建议还是要稳稳的进行,初玩的小朋友可以使用方案2来解决,老手直接方案1即可解决几乎遇到的所有问题。

异常总结

第一种异常要确定我们提交的路径,第二种异常是有冲突的文件,我们平时还是需要多加使用,用的多了也就熟悉了,特别是学生,一定在学校尽可能的遇到更多的异常,这样在工作的时候遇到的问题才能更好的快速解决。

配置SSH的步骤与命令

昵称以及邮箱配置:

git config --global user.name "your Name"
git config --global user.email "your email"

配置列表:

git config --global --list

获取公钥:

ssh-keygen -t rsa -C "配置的邮箱"

查看公钥:

cat ~/.ssh/id_rsa.pub

配置公钥:

直接在个人设置中找到SSH Keys进行添加公钥即可,后面我们就可以正常使用我们的git进行克隆等操作了。

相关文章
|
3月前
|
开发工具 git
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
299 3
git 使用之remote: File [4e21e71a555febaa4dfaaa05cf7eeb606ea96ae2] size 104.090MB, exceeds quota 100MB remote: Please remove the file[s] from history and try again 报错如何解决-优雅草卓伊凡
|
6月前
|
网络安全 开发工具 git
解决fatal:remote error:You can’t push to git://github.com/username/*.g
通过上述诊断与修复步骤,绝大多数的推送错误都能得到有效解决,确保您的Git工作流顺畅无阻。
369 1
|
9月前
|
网络安全 开发工具 数据安全/隐私保护
Win10使用Git克隆项目出现fatal: Authentication failed for异常
Windows 10系统中使用Git克隆项目时出现"fatal: Authentication failed for"异常的解决方法,主要是通过修改凭据管理器中的Git凭据密码来解决因密码过期导致的身份验证失败问题。
274 0
Win10使用Git克隆项目出现fatal: Authentication failed for异常
|
9月前
|
Ubuntu 开发工具 git
ubuntu 14.04的git 错误: gnutls_handshake() failed: Handshake failed
本文提供了一个解决Ubuntu 14.04系统上使用Git时遇到的"gnutls_handshake() failed: Handshake failed"错误的脚本,通过替换git的默认加密传输库gnutls为更稳定的openssl,并指导如何编译安装新版本的git来解决问题。
330 0
|
11月前
|
Shell 开发工具 git
git拉去代码报错"Failed to connect to 127.0.0.1 port 31181: Connection refused"
在克隆`https://example.git/`时遇到错误:"fatal: unable to access 'https://example.git/': Failed to connect to 127.0.0.1 port 31181: Connection refused"。原因是Windows上代理设置未正确关闭,影响了Git配置。解决方法是通过git bash运行命令检查并取消代理:`git config --global http.proxy`和`git config --global --unset http.proxy`。
263 1
 git拉去代码报错"Failed to connect to 127.0.0.1 port 31181: Connection refused"
|
11月前
|
开发工具 git
蓝易云 - 解决git clone时出现Failed to connect to 127.0.0.1 port 1573问题
希望这些信息能帮助你解决问题。如果问题仍然存在,可能需要检查你的网络设置或者联系你的网络管理员。
172 3
|
11月前
|
开发工具 git
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
【已解决】error: failed to push some refs to ‘git@github.com:BATdalao/Github-green.git‘
|
11月前
|
存储 开发工具 git
解决“hint: the same ref. If you want to integrate the remote changes, usehint: ‘git pull‘ before pus”
解决“hint: the same ref. If you want to integrate the remote changes, usehint: ‘git pull‘ before pus”
270 3
|
11月前
|
开发工具 git
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
出现“error: failed to push some refs to ‘https://github.com/****.git‘”,如何解决问题
1236 1
|
11月前
|
开发工具 git
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git
MAC如何使用Git命令行上传本地项目及理解,failed to push some refs to ‘https://gitee.com/brother-barking/spxx.git