zoukankan      html  css  js  c++  java
  • 使用git遇到的一些错误的解决方式

      首先明确使用git的用处,它作为版本控制工具,上传/更新项目到github。

      其次明确git的工作原理。

      先将项目放在工作区(即本地仓库),然后通过add操作放到版本库的暂存区(这个过程使得本地仓库要上传的文件被跟踪),再通过commit操作放到版本库的当前分支。接下来将本地仓库和github的远程服务器仓库关联起来,再执行push操作。这里关联有两种方式,一是通过ssh密钥方式,一是通过remote操作关联url地址。

      但是,在具体操作中会出现一些大大小小的问题和错误,一下记录遇到的坑和可能有效的解决方式。

    1、进行push操作的时候,提示

    fatal: refusing to merge unrelated histories

    或者

    error: failed to push some refs to 'https://github.com/***********’
    hint: Updates were rejected because the tip of your current branch is behind
    hint: its remote counterpart. Integrate the remote changes (e.g.
    hint: 'git pull ...') before pushing again.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.

    造成以上错误的原因有可能是这样的:

       上图是我们在github上创建仓库的页面,勾选了创建README的选项。那么生成的远端库就会有一个README.md文件,这个文件跟我们本地库没有关系(要知道我们从本地库上传到远端库的文件都是经过add操作,即被跟踪了的)

      这就造成了我们push还是pull的时候,远端库觉得本地库跟自己没关系,导致操作失败。

      比较简单的解决方法有2种:

    1)在创建仓库的时候不要勾选那个选项

    2)在进行pull操作前,在git-bash终端输入

    git pull origin master --allow-unrelated-histories //把两段不相干的分支进行强行合并

     2、进行commit操作的时候,提示

    On branch master
    nothing to commit, working tree clean

    应该有挺多可能的原因,我遇到这个问题是因为上面那个坑。解决上面那个坑后,在add后直接push就成功了。

    3、上传vs项目,进行add操作的时候,提示

    error: open(".vs/ExperimentImg/v16/Browse.VC.opendb"): Permission denied
    error: unable to index file '.vs/ExperimentImg/v16/Browse.VC.opendb'
    fatal: adding files failed
    

     借鉴:https://www.cnblogs.com/Fred1987/p/10934705.html

    4、进行remote操作时,提示

    fatal: remote origin already exists.

    输入:git remote rm origin

    重新进行remote操作

     5、进行push操作时,提示

    remote: error: GH001: Large files detected. You may want to try Git Large File Storage - https://git
    

    原因是我们上传的项目太大了,超过了100m

    参考

    https://www.baidu.com/link?url=Sog5uh5H2Tb7GfWe9i9NJUgpQVCIOYGNYW_DSogOYxuYM1c6ISFGsn0PSPN7fEMU&wd=&eqid=d1f02c5b000903ad000000065e6ca0a8

    https://www.baidu.com/link?url=etDTxLLpc8YF4x0mW3nSMP6cR1ZPWiWTE4XZ9jhutjkjUeoWIjdLNjKlEhOI2tRy&wd=&eqid=d1f02c5b000903ad000000065e6ca0a8

    ------------恢复内容结束------------

  • 相关阅读:
    判断两个对象是否相同
    参数的修饰符
    异常处理
    类型转换
    值类型和引用类型
    抽象方法实现计算器
    静态
    多态
    访问修饰符
    面向对象三大特性
  • 原文地址:https://www.cnblogs.com/pskcoco/p/12448792.html
Copyright © 2011-2022 走看看