当前位置:首页 > 移动开发 > 正文

fatal:'origin' does not appear to be a git r

2024-03-31 移动开发

天gitlab中遇到的问题:

当 git push origin branch_name时遇到报错如下:

fatal:‘origin‘ does not appear to be a git repository

fatal:Could not read from remote repository

原因:

本地分支和远程分支断开连接

解决方法:

cd 本地分支里
1、git branch
               ——*master   只显示master

然后查看是否从上游拉了
2、git remote –v
             ——若什么都没有,则和上游已断联系,拉不了代码也推不了代码


加关联
3、git remote add origin ssh://[email protected]*********************************.git(地址)


然后
4、git fetch origin

              ——会显示下拉的branch情况

                    格式为From ssh://gitlab.********************************

                  *  [new branch]         XXXXX        ->origin/XXXXX
 
再次检查远程仓库,显示对应的clone地址
git remote –v
——origin  git://github.com/schacon/ticgit.git (fetch)
origin  git://github.com/schacon/ticgit.git (push)
 
然后再查分支
git branch –a

            ——* mater

                   remotes/origin/XXXXXX         **********

具体的切换分支可参考https://blog.csdn.net/tanningzhong/article/details/79724488

git 重命名仓库、修改远程仓库地址、修改仓库配置可参考:https://blog.csdn.net/u011884440/article/details/71246572

 
---------------------
作者:huanhuaqian
来源:CSDN
原文:https://blog.csdn.net/huanhuaqian/article/details/81986064
版权声明:本文为博主原创文章,转载请附上博文链接!

温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/yidong/26274.html