Git-本地文件关联远程Git库文件

本文详细介绍了在删除Git配置信息后如何重新关联Git库的步骤,并针对执行过程中可能遇到的错误提供了具体的解决方案,包括认证失败、分支上游设置、历史记录合并冲突等问题。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

在我们第一次关联Git库后,如果把Git配置信息删掉了,那么我们需要进行第二次关联:

一、git init

二、git remote add origin "Git库地址"

三、git add . 将本地工程文件夹所有内容添加至缓存区

四、git commit - m "信息关联"

五、git push

执行第五步可能出错:

fatal: Authentication failed for 'Git库地址'

解决:执行第六步:

六、git config --global user.name "用户名";git config --global user.email "邮箱"

执行第五步可能出错:

fatal:The current branch master has no upstream branch.

To push the current branch and set the remote as upstream,use git push --set-upstream origin master

解决:执行第七步:

七、git push --set-upstream origin master

执行第六步可能出错:

error: failed to push some refs to 'Git库地址

解决:执行第八步

八、git pull origin master

执行第八步可能出错:

fatal: refusing to merge unrelated histories 

解决:执行第九步

九、git pull origin master --allow-unrelated-histories

执行第九步后可能提示:

Automatic merge failed; fix conflicts and then commit the result.

然后重新执行:

git branch --set-upstream-to=origin/master master

文章参考:https://blog.youkuaiyun.com/Micheal_ZJ/article/details/79537401

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值