git 使用中问题收集

问题一

问题描述

执行 git push origin 时报错,如下:
在这里插入图片描述

解决办法

执行

git remote add code-na2 git@github.com:code-na2/mos-mss.git

即发现远程仓库有问题,所以重新关联到新的远程仓库。

解决过程
  1. 查看本地配置
git config -- list    查看当前项目下所有 git 相关配置

配置结果:
在这里插入图片描述

credential.helper=osxkeychain
user.name=赵娜
user.email=zhaona12@meituan.com
url.https://.insteadof=git://
url.git://.insteadof=https://
core.repositoryformatversion=0
core.filemode=true
core.bare=false
core.logallrefupdates=true
core.ignorecase=true
core.precomposeunicode=true
remote.origin.url=https://github.com/gitna2/mos-mss.git
remote.origin.fetch=+refs/heads/*:refs/remotes/origin/*
branch.master.remote=origin
branch.master.merge=refs/heads/master
branch.feature-5721399.remote=origin
branch.feature-5721399.merge=refs/heads/master
remote.upstream.url=https://github.com/gitna2/mos-mss.git
remote.upstream.fetch=+refs/heads/*:refs/remotes/upstream/*

即包含用户名、邮箱、所有关联的远程仓库 remote(这里是origin、upstream)、及对应仓库下分支。

从结果发现远程仓库配置url有问题,故可删除现有错误配置,重新设置远程仓库。

  1. 重新关联现有远程仓库相关设置或直接新建一个远程配置

先删除现有 origin 关联(直接新建远程配置时不用):

git remote remove origin

再添加新的远端仓库并设置别名,这里使用别名 code-na2:

git remote add code-na2 git@github.com:code-na2/mos-mss.git
  1. 查看本地仓库下 branch
git branch -r

发现没有关联分支,所以要拉取代码:

git fetch code-na2

这样,再执行:

git push origin feature-5721399

就成功了
在这里插入图片描述

涉及关键命令
git config -- list    查看当前项目下所有 git 相关配置
git remote remove origin		删除现有远端仓库关联
git remote add code-na2 git@github.com:code-na2/mos-mss.git		添加远端仓库关联
git fetch code-na2		从远端拉去分支
git branch -r		本地所有仓库下 branch
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值