zoukankan      html  css  js  c++  java
  • git错误记录

    未有特别说明均为原创,转载请注明出处

    1.查看远程仓库地址:git remote show origin
    2.假如你没有了.git文件夹。那么你做操作时候可能报错

    fatal: Not a git repository (or any of the parent directories): .git
    

    提示说没有.git这样一个目录,解决办法如下:

    git init
    

    但是你只是生成了一个空的git文件,没有任何关于仓库和版本的信息。
    所以你还会遇到下面错误

     $ git remote show origin
     
    fatal: 'origin' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    
    
    

    解决办法1是设置仓库url

     git remote set-url origin https://gitee.com/XXX/XXX
     //当然我们这里新建的.git文件没有仓库,如果有的话,先删后建
    git remote rm origin
    git remote add origin [url]
    //也可以直接修改config文件
    
    

    2是将关联远程仓库为origin

    git remote add origin git@github:YOUACCOUNT/YOURPROJECT.git
     
    

    注意上面我猜应该是用master.但是我用于origin,所以发生了一些列有趣的事情。

    gin https://gitee.com/XXX/XXX
    PS F:GitXXX> git remote show origin
    * remote origin
     Fetch URL: https://gitee.com/XXX/XXX
     Push  URL: https://gitee.com/XXX/XXX
     HEAD branch: master
     Remote branch:
       master new (next fetch will store in remotes/origin)
    

    可以看到查询远程仓库地址是origin
    先不管,我们头大直接提交

    git add -A
    git commit -m "--"
    git pull
    

    好了pull出问题了

    PS F:GitXXX> git pull
    From https://gitee.com/XXX/XXX
     * [new branch]      master     -> origin/master
    There is no tracking information for the current branch.
    Please specify which branch you want to merge with.
    See git-pull(1) for details.
    
        git pull <remote> <branch>
    
    If you wish to set tracking information for this branch you can do so with:
    
        git branch --set-upstream-to=origin/<branch> master
    

    意思是拉错分支了。所以

    git pull origin master
    From https://gitee.com/XXX/XXX
     * branch            master     -> FETCH_HEAD
    fatal: refusing to merge unrelated histories
    //所以正确的应该是
    git pull origin master --allow-unrelated-histories
    
    //如果你仍然硬着头皮拉 
    //git pull origin
    /*
    You asked to pull from the remote 'origin', but did not specify
    a branch. Because this is not the default configured remote
    for your current branch, you must specify a branch on the command line.
    */
    //或者 git pull remote origin
    /*
    fatal: 'remote' does not appear to be a git repository
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    */
    

    之后 如果有冲突记得合并冲突,重新
    addcommitpull origin master --allow-unrelated-histories
    步骤同上
    最后提交

     git push --set-upstream origin master
    

  • 相关阅读:
    ajax加载数据字典下拉选后台
    【算法】二叉树前中后序的递归+迭代(java代码)
    【设计模式】代理模式与装饰器模式的区别
    《重构》读书笔记(一)
    【服务器安全】记一次处理挖矿病毒经历
    【计算机原理】数值存储计算基本理论(一)
    【JAVA】java中类的执行顺序
    【numpy&pandas】Pandas速查笔记
    【前端】打包vue项目到nginx过程
    【服务器搭建】Linux下安装docker
  • 原文地址:https://www.cnblogs.com/marvelousone/p/11273629.html
Copyright © 2011-2022 走看看